sketchucation logo sketchucation
    • Login
    1. Home
    2. kwalkerman
    3. Posts
    ℹ️ 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 28
    • Posts 148
    • Groups 1

    Posts

    Recent Best Controversial
    • RE: Find the global position of a Vertex in a Group/Component

      one small correction to the code posted by Glenn: after calling createVerticesArray on line 14, add the line:

      trans_h.pop

      otherwise, if there are multiple sub-components in the entities collection, you will take into account the transformation of any entity that came before.

      Otherwise, great code, very useful.

      Thanks!

      --
      Karen

      posted in Developers' Forum
      K
      kwalkerman
    • RE: Dynamic Components and Glue To

      A DC tech reference would be pretty awesome. Thanks!

      --
      Karen

      posted in Developers' Forum
      K
      kwalkerman
    • RE: Dynamic Components and Glue To

      Dan,

      I have been watching ThomThom's "state of observers" forum. And (assuming all observers are working correctly), I can think of some ways to use observers to 'watch' entities and feed information back to a ruby script, which does some calculations. The real problem is in the DC interface. I was hoping that someone here knew an unpublished way to access information about components that we can get using ruby code, directly in the DC interface.

      --
      Karen

      posted in Developers' Forum
      K
      kwalkerman
    • Dynamic Components and Glue To

      I'm not sure if this is the best forum for this, but I'll give it a try...

      Does anyone know of a way to have simple dynamic component pull information from it's "glued_to" surface. I think this may really be part of a larger question, which is how to go beyond simple spreadsheet-like formulas in dynamic components to something really useful.

      I can think of a way to do this if I can create a number in a ruby file, and then send it to the DC. I have followed the advice from Scott Lininger's post (http://forums.sketchucation.com/viewtopic.php?f=180&t=24241) regarding creating dynamic components in ruby. First, no mater what I enter for units, the dynamic component units are the default text. Second, once I have created the variable, if I change the units in the DC attributes editor, I can't change it using ruby code by simply saying x.set_attribute.

      Any ideas?

      Thanks,

      --
      Karen

      posted in Developers' Forum
      K
      kwalkerman
    • RE: Face.clone

      Didier - thanks for posting this. For my current purposes, I sometimes have another face bounded by the inner loops that I don't want to erase, so If I copy a bunch of faces together, and copy the inner loop faces first, then they'll get deleted when I copy the outer faces. So, creating a group, copying the group, and immediately exploding the original group is the best method for me.

      Dan - thanks for the info on face.clone and face.dup. I saw <Deleted Entity: xxxxxxxxx> pop up in the ruby console, but I just assumed that the face was immediately deleted because it was placed on top of the other face.

      --
      Karen

      posted in Developers' Forum
      K
      kwalkerman
    • RE: Face.clone

      I think that creating it as a group (and I may have a few faces), copying the group and then exploding the group is my best option. I don't want to use the first method because if I have another face (or sub-face if you want to think of it that way) in the hole, and I copied the sub-face first, then deleting the center of the hole will delete the face in the middle.

      It just seemed to me that there should be a simpler way to do this.

      I just tried TIG's method, and it works, although I have had a problem creating and exploding groups using the webconsole. The exact same script that will splat in the webconsole will run fine if I create an external rb file. I think this may be fixed in the next release?

      Thanks as always for your help!!

      --
      Karen

      posted in Developers' Forum
      K
      kwalkerman
    • RE: Face.clone

      So apparently, you can do face.clone, the challenge is having the face around long enough to do anything with it. I would like to add the cloned face to a group. Entities.add_face only accepts arrays of edges or points, not actual faces, is there any way to add an already defined face to a group? I if so, I might be able to determine what is happening with face.clone

      --
      Karen

      posted in Developers' Forum
      K
      kwalkerman
    • Face.clone

      Is there something that will achieve a face.clone or face.copy? Eventually I want something that will copy all information, including materials, textures, etc. At the moment, I'm just trying to copy the geometry. See the image below. The image on the left is the original face. The image in the middle is the result of creating a new face using entities.add_face(face.outer_loop.vertices). The outer geometry is maintained, but not the hole in the middle. Using entities.add_face(face.vertices) results in the shape to the right - not right at all.

      As always, Thanks!

      --
      Karen


      face on the left has a hole, face in the middle is the result of copying based on the outer_loop, and face on the right is the result of adding a face using all the vertices in the face

      posted in Developers' Forum
      K
      kwalkerman
    • RE: Add-On for custom tool to create faces when a line is drawn

      Cool. Thanks.

      posted in Developers' Forum
      K
      kwalkerman
    • Add-On for custom tool to create faces when a line is drawn

      When edges are drawn in custom tools entities.add_edge (pts), faces are not created automatically as with the built-in line tool. I recall seeing documentation somewhere that allows you to do this, but I can't remember where - can anyone point me in the right direction?

      Thanks,

      --
      Karen

      posted in Developers' Forum
      K
      kwalkerman
    • RE: Creating a Custom Line Tool

      Hmm... somehow my 'linetool.rb' file got put in the plugins folder and I didn't know that I had it... There are many differences (other than the obvious ones that theirs draws a construction line not an edge, and doesn't start a new line where the old one leaves off). They also work primarily with input points, where I convert earlier to point3d, which means that to do inferencing, I have to convert back.

      Also, in order to get the tool to write into the active group, $entities = Sketchup.active_model.acitve_entities (not Sketchup.active_model.entities) or (as in 'linetool.rb' view.model.entities).

      --
      Karen

      posted in Developers' Forum
      K
      kwalkerman
    • RE: Creating a Custom Line Tool

      Cool. Here it is formatted. As of right now, the line is always added to Sketchup.model.entities. I will need to have it add to the active path... just haven't gotten there yet. Otherwise, it seems to work.

      --
      Karen

      class Custom_Line
      
      def initialize
       @cursor = UI.create_cursor("Cursor.tiff",1,1)
      end # def initialize
      
      def activate
       $ip = Sketchup;;InputPoint.new
       Sketchup.active_model.selection.clear
       @ip1 = nil
      end
      
      def onSetCursor
       UI.set_cursor(@cursor)
      end
      
      def onMouseMove(flags, x, y, view)
       $ip.pick(view, x, y)
       view.invalidate
      end
      
      def draw(view)
       $ip.draw(view)
       if(@pt1 == nil)
        view = view.draw_line $ip.position, $ip.position
       else 
        Sketchup.vcb_label = @pt1.distance($ip.position).to_s
        view = view.draw_line @pt1, $ip.position #draws line from last point to current position
        view.invalidate
       end
      end
      
      def onKeyUp(key, repeat, flags, view)
       if(key==16)
        view.lock_inference
       end
      end
      
      def enableVCB?
       return true
      end
      
      def onUserText(text, view)
       begin
        if(@pt1 != nil)
         value = text.to_l # convert the value to a length
         point2 = [$ip.position]
         dist = @pt1.distance(point2)
         w2 = value/dist
         w1 = 1-w2
         @pt2 = Geom;;Point3d.linear_combination w1, @pt1, w2, point2
         line = Sketchup.active_model.entities.add_edges @pt1, @pt2 # RIGHT NOW, JUST ADDS TO THE BASE LEVEL
         @pt1 = @pt2
         Sketchup.vcb_value = ''
        end
       rescue
        # Error parsing the text
        UI.beep
        value = nil
       end
      end
      
      def onKeyDown(key, repeat, flags, view)
       if(key==16&&@pt1!=nil)
        ip1 = Sketchup;;InputPoint.new(@pt1)
        @pt2 = $ip.position
        ip2 = Sketchup;;InputPoint.new(@pt2)
        view.lock_inference(ip1,ip2)
       end
      end
      
      def onLButtonUp(flags, x, y, view)
       if(@pt1 == nil)
        @pt1 = [$ip.position]
       else
        @pt2 = [$ip.position]
        line = Sketchup.active_model.entities.add_edges @pt1, @pt2 # RIGHT NOW, JUST ADDS TO THE BASE LEVEL
        @pt1 = @pt2
        Sketchup.active_model.active_view.invalidate
       end 
      end 
      end
      
      posted in Developers' Forum
      K
      kwalkerman
    • RE: Creating a Custom Line Tool

      Ah, too bad. Of course I want a custom move tool and rectangle tool as well. I do have a line tool working with inference locking and and the VCB activated.

      well, for future, I'll post my line tool:

      class Custom_Line

      def initialize
      @cursor = UI.create_cursor("Cursor.tiff",1,1)
      end # def initialize

      def activate
      $ip = Sketchup::InputPoint.new
      Sketchup.active_model.selection.clear
      @ip1 = nil
      end

      def onSetCursor
      UI.set_cursor(@cursor)
      end

      def onMouseMove(flags, x, y, view)
      $ip.pick(view, x, y)
      view.invalidate
      end

      def draw(view)
      $ip.draw(view)
      if(@pt1 == nil)
      view = view.draw_line $ip.position, $ip.position
      else
      Sketchup.vcb_label = @pt1.distance($ip.position).to_s
      view = view.draw_line @pt1, $ip.position #draws line from last point to current position
      view.invalidate
      end
      end

      def onKeyUp(key, repeat, flags, view)
      if(key==16)
      view.lock_inference
      end
      end

      def enableVCB?
      return true
      end

      def onUserText(text, view)
      begin
      if(@pt1 != nil)
      value = text.to_l # convert the value to a length
      point2 = [$ip.position]
      dist = @pt1.distance(point2)
      w2 = value/dist
      w1 = 1-w2
      @pt2 = Geom::Point3d.linear_combination w1, @pt1, w2, point2
      line = Sketchup.active_model.entities.add_edges @pt1, @pt2 # RIGHT NOW, JUST ADDS TO THE BASE LEVEL
      line[0].set_attribute "EPdict", "Tool", "Node/Branch"
      @pt1 = @pt2
      Sketchup.vcb_value = ''
      end
      rescue
      # Error parsing the text
      UI.beep
      value = nil
      end
      end

      def onKeyDown(key, repeat, flags, view)
      if(key==16&&@pt1!=nil)
      ip1 = Sketchup::InputPoint.new(@pt1)
      @pt2 = $ip.position
      ip2 = Sketchup::InputPoint.new(@pt2)
      view.lock_inference(ip1,ip2)
      end
      end

      def onLButtonUp(flags, x, y, view)
      if(@pt1 == nil)
      @pt1 = [$ip.position]
      else
      @pt2 = [$ip.position]
      line = Sketchup.active_model.entities.add_edges @pt1, @pt2 # RIGHT NOW, JUST ADDS TO THE BASE LEVEL
      @pt1 = @pt2
      Sketchup.active_model.active_view.invalidate
      end # if state
      end
      end

      posted in Developers' Forum
      K
      kwalkerman
    • Creating a Custom Line Tool

      Hi,

      I just had an idea. I think it should be possible, but there is no official documentation:

      class Custom_Line_Tool < Sketchup::SketchTool

      def initialize
      super
      end

      def onLButtonUP(flags, x, y, view)

      do whatever special stuff you want...

      end

      end

      This would get us to a place where we can use the native sketchup tool stuff (inference locking, line tool image, use of crosshairs if that is what the user wanted, native use of the VCB...) We could then have the tool do custom things, and treat it as a custom tool. However, 'Sketchup::SketchTool' doesn't return anything useful. Any other ideas of things to try?

      We'd also need to know how native sketchup names the input point, and probably a few other things. I do have a custom line tool working, but the original is just more elegant.

      --
      Karen

      posted in Developers' Forum
      K
      kwalkerman
    • RE: State of Observers — 28 February 2010

      EntityObserver - (and possibly others)

      it seems that OnEraseEntity is activated after onChangeEntity, which means that if the entity is erased, it can cause bugs for whatever you are trying to do with OnChangeEntity. If OnEraseEntity were activated first, you could create a simple boolean value:

      def initialize
      @still_here = true
      end

      def OnEraseEntity(entity)

      whatever you want to do...

      @still_here = false
      end

      def OnChangeEntity(entity)
      if (still_here)

      whatever you want to do...

      end
      end

      This is a problem because the entity seems to be erased before OnChangeEntity is called, which means that doing something to the entity gives errors, but your observer doesn't know it until it gets through OnChangeEntity to OnEraseEntity.

      --
      Karen

      posted in Developers' Forum
      K
      kwalkerman
    • RE: Entities Observer for group

      Ok, I just figured it out for myself, but for future generations:

      group.entities.add_observer (MyEntitiesObserver.new)

      !!!

      --
      Karen

      posted in Plugins
      K
      kwalkerman
    • Entities Observer for group

      Hi,

      I'm trying to monitor a group, and report any time there is a change within the group. The EntityObserver class reports only when the group itself is moved or rotated, not when there is a change inside the group. How do I create one just for the entities within a group?

      Thanks!

      --
      Karen

      posted in Plugins
      K
      kwalkerman
    • RE: Use of tools within tools?

      Jeff,

      yes, this is what happens when you create a block, and then move the block (which is why I chose that method of executing the slippery move). You can also copy something, move the copy and delete the original, which would result in a hole in your yellow box (front face still existing).

      --
      Karen

      posted in Plugins
      K
      kwalkerman
    • RE: Use of tools within tools?
      1. I use shortcuts, all the time. The idea is that the tool would take care of some of the stuff automatically, and then give you the next tool you need, taking fewer keystrokes.

      2. I generally use the program for architecture, currently I'm designing a post and beam barn. I often find myself copying lines, and deleting the original (another way to accomplish a "slippery move"), especially when creating the roof geometry with dormers, etc. This is partly because I'm stubborn and I like my walls and roofs to be thick, ie have two sides.

      3. I'm learning to program ruby, and I figured this would be an "easy" first plugin I could create in order to facilitate learning (and that would be useful later on). Am I really the only one who thinks being able to call tools within tools would be useful?

      4. I thought that calling an already existing tool would be the easiest way to do what I'm looking to do, but I guess I'll need to re-create the move and select tools. Chris - can you send me a link to the sample code you created for August? I'd really appreciate it.

      Thanks for all your help and comments.

      --
      Karen

      posted in Plugins
      K
      kwalkerman
    • RE: Use of tools within tools?

      The problem is that there are certain things I do all the time, in the same order, and I want to make it faster.

      Right now, I'm trying to create a "Slippery Move" tool, where you can move things without having them stick, or have them stick only to selected objects. The sequence for the basic Slippery Move is to select some things, make a group out of them, move the group, and then explode the group. The sequence for selected Slippery Move is to select some objects to move, then select which things you want it to stick to. The tool will make a group out of the "slippery" objects, allow the user to move the objects selected for the move, and then explode the group.

      For obvious reasons, being able to say "use select tool until... (enter or keystroke)" or "use move tool until... (enter or keystroke)" would be extremely useful in this situation. I really want to have all the functionality of the built-in select and move tools so that the Slippery Move tool operates in ways that the user expects. Having to re-create all that functionality seems ridiculous.

      posted in Plugins
      K
      kwalkerman
    • 1 / 1