sketchucation logo sketchucation
    • Login
    1. Home
    2. kmk111890
    3. Topics
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info
    K
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 9
    • Posts 18
    • Groups 1

    Topics

    • K

      Error message : 'reference to deleted Entities'

      Watching Ignoring Scheduled Pinned Locked Moved Developers' Forum
      6
      0 Votes
      6 Posts
      1k Views
      J
      Wild guess - he started a New model and so the @entities variable now refers to an invalid collection.
    • K

      Strayed coordinates

      Watching Ignoring Scheduled Pinned Locked Moved Newbie Forum sketchup
      2
      0 Votes
      2 Posts
      265 Views
      S
      Without seeing your code, this is just a guess, but I suspect that you are falling victim to the fact that all coordinates in SketchUp are internally represented as inches, regardless of the visible units you have set for the model. So, 1000mm=39.37inches. Apply #to_i and you get 39 inches = 990.6mm.
    • K

      Generating coordinates with Ruby

      Watching Ignoring Scheduled Pinned Locked Moved Newbie Forum sketchup
      6
      0 Votes
      6 Posts
      385 Views
      sdmitchS
      @kmk111890 said: Thank you, sdmitch and TIG. I could partly understand how i have to fix the codes, but not perfect because I showed you code roughly. Maybe, it would be better i show you what i'm doing now. I'm trying to add bezier curve to draw one simple shape. The equation for the quadratic bezier curve represents as shown below B(t) = (1-t)(1-t)P0+2(1-t)P1+(t)(t)P2 With the equation, I tried to generate coordinates which are from the equation and wanted to use 'For loop'. hmmm It looked like i can make the codes by myself, but didn't work well This seems to work ents = Sketchup.active_model.entities Length = 1000 angle = (60)/2 angle2 = (45)/2 pt0 = [0,0,0] pt1 = [Length.mm, 0, 0] aa = 80*0.01 pt2 = pt1.transform(Geom;;Transformation.rotation(pt0,[0,-1,0],angle.degrees)) pt3 = pt1.transform(Geom;;Transformation.rotation(pt0,[0,-1,0],angle2.degrees)) pt4 = [Length.mm*aa, 0, 0] pt5 = pt4.transform(Geom;;Transformation.rotation(pt0,[0,-1,0],angle.degrees)) arcarray = ents.add_arc [0,0,0], [1,0,0],[0,-1,0], Length.mm, 0, angle2.degrees arc = arcarray[0] arccurve = arc.curve verts = arccurve.vertices pts=[];pts<<pt0 0.step(1,0.2) do |t1| x = (1-(t1))*(1-(t1))*pt5.x+2*(1-(t1))*(t1)*pt2.x+(t1)*(t1)*pt3.x y = (1-(t1))*(1-(t1))*pt5.y+2*(1-(t1))*(t1)*pt2.y+(t1)*(t1)*pt3.y z = (1-(t1))*(1-(t1))*pt5.z+2*(1-(t1))*(t1)*pt2.z+(t1)*(t1)*pt3.z pts << Geom;;Point3d.new(x, y, z) end pts<<pt1 a = ents.add_line pt0, pt1 b = ents.add_line pt0, pt5 c = ents.add_curve pts face = ents.add_face pts path = ents.add_circle [Length,0,0], [-1,0,0], -Length face.followme path ents.erase_entities path face2 = ents.add_face verts path2 = ents.add_circle [Length,0,0], [-1,0,0], -Length face2.followme path2 ents.erase_entities path2 group=ents.add_group ents.to_a [image: 0MNz_kmk.gif]
    • K

      Code correction

      Watching Ignoring Scheduled Pinned Locked Moved Newbie Forum sketchup
      7
      0 Votes
      7 Posts
      465 Views
      K
      Hi, TIG. Finally, Its working as I have hoped. This is the corrected code. I needed not use 'group'. The cone shape is created after I deleted the line. Thank you! require 'sketchup.rb' class Cone @@Length = @@angle =@@x=@@y=@@z = nil def create_cone @@Length = 100 if not @@Length @@angle = 30.0 if not @@angle @@x = 0.mm if not @@x @@y = 0.mm if not @@y @@z = 0.mm if not @@z prompts = ["Radius","Angle", "x", "y", "z"] values = [@@Length, @@angle, @@x, @@y, @@z] results = inputbox prompts, values, "Fire sensor" if results @@Length, @@angle, @@x, @@y, @@z = results model = Sketchup.active_model model.start_operation "Fire sensor" compdef = Sketchup.active_model.definitions.add ents = compdef.entities @Length = @@Length.mm @angle = (@@angle.degrees)/2 @pt0 = [0,0,0] @pt1 = [0, 0, -@Length] @pt2=@pt1.transform(Geom;;Transformation.rotation(@pt0,[0,-1,0],@angle)) arcarray = ents.add_arc [0,0,0], [0,0,-1],[0,-1,0], @Length, 0, @angle arc = arcarray[0] arccurve = arc.curve verts = arccurve.vertices a = ents.add_line @pt0, @pt1 b = ents.add_line @pt0, @pt2 face = ents.add_face @pt0, @pt1, @pt2 path = ents.add_circle [0,0,-@Length], [0,0,1], -@Length face.followme path ents.erase_entities path face2 = ents.add_face verts path2 = ents.add_circle [0,0,-@Length], [0,0,1], -@Length face2.followme path2 ents.erase_entities path2 trans = Geom;;Transformation.new([@@x.to_i, @@y.to_i, @@z.to_i]) status=model.place_component(compdef) Sketchup.active_model.active_entities.add_instance(compdef, trans) model.commit_operation end #if Sketchup.send_action 'selectSelectionTool;' end #def end #Class if( not file_loaded?(__FILE__) ) UI.add_context_menu_handler do |menu| end dir=File.dirname(__FILE__) cmd_array = [] cmd = UI;;Toolbar.new "sphere" # Create the Command object cmd = UI;;Command.new("Cone") {Sketchup.active_model.select_tool Cone.new.create_cone} # Configure the Command's appearance cmd.small_icon = cmd.large_icon = dir+"/FGmanual/images/cone.png"#<-- cmd.tooltip = "Cone" cmd_array.push(cmd) tb=UI;;Toolbar.new("Creating tools") cmd_array.each {|i| tb.add_item(i)} tb.show if tb.get_last_state == -1 end file_loaded(__FILE__)
    • K

      Correction of codes

      Watching Ignoring Scheduled Pinned Locked Moved Developers' Forum
      4
      0 Votes
      4 Posts
      366 Views
      K
      Thanks, sdmitch and slbaumgartner. Now It works well However, I'm planning to create some shapes more with this way and actually made few shapes. I'm worrying about increase of icons in Sketchup, and am making ideas how to simplify tools. Making dialog box I saw some free tools which 'inputbox' is added together. If the shapes can be individually selected in inputbox, I need not add icons anymore, but don't know how to make it. I know basic codes for creating inputbox, and would like to apply the basic code to what I want(choosing each shapes individually in inputbox). Additionally, Is it possible to add shapes which are saved in .skp file(I know how to load shapes saved in .skp file by using 'Class' method and how to place it on Sketchup space clicking) into inputbox too? Using webdialog If i create webdialog box and add all icons into the webdialog by making tables(categorization), This way may look good as well. I'm trying to use dlg.add_action_callback("") {|d, p|Sketchup.send_action ""} Can i utilize this command for making icons in webdialog? I mean, the command looked like only basic tools(Undo, Redo, New, Cut, PushPull) can be used with the command. For example dlg.add_action_callback("Undo") {|d, p|Sketchup.send_action "editUndo:"} dlg.add_action_callback("Redo") {|d, p|Sketchup.send_action "editRedo:"} dlg.add_action_callback("New") {|d, p|Sketchup.send_action 57600} dlg.add_action_callback("Open") {|d, p|Sketchup.send_action 57601} dlg.add_action_callback("Save") {|d, p|Sketchup.send_action 57603} As you know, these actions are used in HTML and '<scrip> </script>' connects between ruby codes and HTML codes for indicating icons in webdialog. How can I make my own Sketchup.send_action? If it is possible, I will add the icons into webdialog.
    • K

      Ray casting

      Watching Ignoring Scheduled Pinned Locked Moved Newbie Forum sketchup
      3
      0 Votes
      3 Posts
      260 Views
      K
      For better understanding, I attached two images more. I got a example of ray casting on google and wanna express it into second picture. As you can see, This is just combination of cone and cylinder. If ray casting is added, invisible area behind cylinder should be occurred. In other word, all parts of cone shape behind cylinder automatically have to be deleted. I would like to apply ray casting into usual shapes [image: xGCs_34.png] [image: SDUa_.JPG]
    • K

      Possibility of partly removal of overlapped solid figure

      Watching Ignoring Scheduled Pinned Locked Moved Newbie Forum sketchup
      1
      0 Votes
      1 Posts
      237 Views
      No one has replied
    • K

      Drawing Sphere with ruby

      Watching Ignoring Scheduled Pinned Locked Moved Newbie Forum sketchup
      2
      0 Votes
      2 Posts
      1k Views
      S
      See comments regarding various errors: ` require 'sketchup.rb' def create_sphere @radius = 0.feet if not @radius # along Green Y axis prompts = ["radius", "R", "G", "B"] values = [@radius, @R, @G, @B] results = inputbox prompts, values, "Sphere" return if not results @radius, @R, @G, @B,= results model = Sketchup.active_model # why keep switching between model and Sketchup.active_model? model.start_operation "Sphere" compdef = Sketchup.active_model.definitions.add # needed 's' multiple places show confusion between an Entity and its Entities collection ents = compdef.entities center = [0, 0, 0] radius = @radius circle = ents.add_circle center, [0, 0, 1], radius circle_face = ents.add_face circle assign these right away - the followme will destroy the original circle_face Color.new needs integers not strings circle_face.material=Sketchup::Color.new(@R.to_i, @G.to_i, @B.to_i) circle_face.material.alpha = 0.3 path = ents.add_circle center, [0, 1, 0], radius + 1 circle_face.followme path ents.erase_entities path place_component activates the Tool to manually place a ComponentInstance via GUI add_instance explicitly places one via Ruby You probably don't want to do both? #status=model.place_component(compdef) need to create trans before you can use it! This creates an identity, which adds the instance at the model origin trans=Geom::Transformation.new Sketchup.active_model.active_entities.add_instance(compdef, trans) model.commit_operation end if( not file_loaded?("Sphere.rb") ) utilities_menu = UI.menu("Plugins").add_submenu("Sphere") utilities_menu.add_item("Sphere") { create_sphere } end #----------------------------------------------------------------------------- file_loaded("Sphere.rb")` Also, you should isolate your code in a module so that the method does not go into the global namespace.
    • K

      Making submenu

      Watching Ignoring Scheduled Pinned Locked Moved Developers' Forum
      7
      0 Votes
      7 Posts
      578 Views
      K
      Ok, Thanks, Dan I will be able to fix it by myself ) Thank you!!
    • 1 / 1