sketchucation logo sketchucation
    • Login
    1. Home
    2. kwalkerman
    🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now
    K
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 28
    • Posts 148
    • Groups 1

    kwalkerman

    @kwalkerman

    10
    Reputation
    1
    Profile views
    148
    Posts
    0
    Followers
    0
    Following
    Joined
    Last Online

    kwalkerman Unfollow Follow
    registered-users

    Latest posts made by kwalkerman

    • RE: [Plugin] TIG-Smart_offset

      Hi TIG - I got something working for my test case. I've inserted the following code at line 834:

      ### CODE BY KAREN WALKERMAN
      face.outer_loop.edges.each do |edge|
         t1 = get_90_trans(face,edge,edge.start.position,dist)
         t2 = get_90_trans(face,edge,edge.end.position,dist)
         p1 = edge.start.position.transform(t1)
         v1 = edge.line[1].reverse
         v1.length = dist
         p1.transform! Geom;;Transformation.new(v1)
         p2 = edge.end.position.transform(t2)
         v2 = edge.line[1]
         v2.length = dist
         p2.transform! Geom;;Transformation.new(v2)
         line = gents.add_line(p1,p2)
      end
      			gp.entities.intersect_with(true,gp.transformation,gp.entities,gp.transformation,false,gp)
      edges = []
      gents.each{|e| edges << e if e.is_a? Sketchup;;Edge}
      edges.each{|e| e.find_faces}
      togos = []
      gents.each do |e|
         if e.is_a? Sketchup;;Edge
            if e.faces.length != 1
               togos << e
            end
         end
      end
      gents.erase_entities(togos)
      # now add back original edges
      o_points = []
      face.outer_loop.vertices.each{|v| o_points << v.position}
      gents.add_face(o_points)
      ### END CODE BY KAREN WALKERMAN
      

      I've also added a method:

      def self.get_90_trans(face,edge,p,length)
         if edge.reversed_in? face
            t = Geom;;Transformation.rotation(p,face.normal,Math;;PI/2)
         else
            t = Geom;;Transformation.rotation(p,face.normal,-Math;;PI/2)
         end
         trans_vector = edge.line[1].transform t
         trans_vector.length = length
         #Vector3d_Functions.round_vector_keep_length(trans_vector,6)
         new_t = Geom;;Transformation.new(trans_vector)
         return new_t
      end
      

      what's the best way to test this further and (if successful) integrate it into the code?

      I gather that with the updates to the native offset tool, people are probably not using this tool directly anymore, but for me it is helpful to be able to call an offset programmatically.


      TIG-Smart_offset.rb

      posted in Plugins
      K
      kwalkerman
    • RE: [Plugin] TIG-Smart_offset

      Ah, there you go. Thank you!

      If I figure out how to make it work for this face, I'll let you know with the updates.

      posted in Plugins
      K
      kwalkerman
    • RE: [Plugin] TIG-Smart_offset

      Hi TIG,

      The file I downloaded is "TIG_Smart_offset_v3.0.rbz"

      Forgive me - I've done extensive coding for my own use, but very little with other people's files. My understanding of *.rbz is that is a protected format and there isn't a way to view the original *.rb.

      I am getting one error related to Fixnum being deprecated, but the tool is also simply not offsetting for one of my test faces. It's a tricky face, and I haven't been able to write my own offset tool that works for it, which is how I came across your tool. (see below):


      Capture.PNG

      posted in Plugins
      K
      kwalkerman
    • RE: [Plugin] TIG-Smart_offset

      Hi TIG - I wonder if you'd give me access to the original ruby code - the plugin is not working in my 2020 version of SketchUP and I'd be interested in trouble-shooting the code.

      Thanks!

      Karen

      posted in Plugins
      K
      kwalkerman
    • RE: Changes in 2015

      yes, all those workarounds work... But wouldn't it have made more sense to leave point.x as a float as it has always been? In 2015 to convert any number to a length, you just have to do num.to_l so if you wanted point.x as a length all you would need to do is: point.x.to_l ... and all of us who wrote code years ago don't have to go back and tease out the old code...

      This one hasn't tripped me up as much as I thought it would so far... just needed to add .to_f in a few places.

      posted in Developers' Forum
      K
      kwalkerman
    • Changes in 2015

      Hi - I thought I would create a place to log some changes in SU 2015. I just started playing with 2015 and I've noticed one change that will be pretty significant for some tools:

      In previous versions of SU, x,y and z coordinates of a Point3d were always returned as a float with the units being inches. Similarly, the length of an edge was always returned as a float with the units being inches. In SU 2015, the x,y and z coordinates of a Point3d are returned as a "Length" with the units being the current model units. The length of an edge is handled the same way.

      The area of a face is still a float, with the units being square inches.

      This seems like a bad move for backwards compatibility.

      posted in Developers' Forum
      K
      kwalkerman
    • RE: EntitiesObserver Weirdness

      Hi Dan,

      Holding a reference does't make any difference. The only time the reference held by @m is actually stored is when the observer is assigned to Sketchup.active_model.entities.

      Also, I noticed that in cases where I have a new file, and I first add the observer to a group's entities collection, the observer does not alert onElementModified for the material. It only alerts for the face.

      Thanks,

      --
      Karen

      posted in Developers' Forum
      K
      kwalkerman
    • EntitiesObserver Weirdness

      OK. I have repeatable steps for the Sketchup:EntitiesObserver that show some STRANGE behavior.

      Use this code:

      ` class KW_EntitiesObserver_Weirdness < Sketchup::EntitiesObserver
      def initialize(*args)
      super
      @m = nil
      end
      def onActiveSectionPlaneChanged(entities)
      end
      def onElementAdded(entities,entity)
      end
      def onElementModified(entities,entity)
      puts "onElementModified: #{entity}"
      if entity.is_a? Sketchup::Material
      @m = entity
      end
      puts "material is #{@m}"
      end
      def onElementRemoved(entities,entity)
      end
      def onEraseEntities(entities)
      end

      def method_missing(meth,*args,&block)
      end
      

      end`

      Materials Weirdness:

      1. In Sketchup, draw a few faces. Enclose them in a group
      2. Load the code above
      3. Select the group
      4. Do the following in the ruby console:

      s = Sketchup.active_model.selection s[0].entities.add_observer KW_EntitiesObserver_Weirdness.new

      1. Now change the material of one of the faces in the group. The observer will fire (at least) twice. In my case it sometimes fires three times - the first two times for the material. The console output should look like this:

      onElementModified: #<Sketchup::Material:0x9c2328> material is #<Sketchup::Material:0x9c2328> onElementModified: #<Sketchup::Face:0xa77588> material is

      For some reason, the material that was stored as @m after the first observer call has been lost. Even more strange, if you add the observer, to Sketchup.active_model.entities everything works fine. The steps for this are:

      1. In Sketchup, draw a few faces.
      2. Load the code above
      3. In the ruby console:

      Sketchup.active_model.entities.add_observer KW_EntitiesObserver_Weirdness.new

      1. Now change the material of one of the faces in the group. Again, the observer fires (at least) twice. In my case it sometimes fires three times - the first two times for the material. In any case @m maintains the reference to the material:

      onElementModified: #<Sketchup::Material:0x98b3c8> material is #<Sketchup::Material:0x98b3c8> onElementModified: #<Sketchup::Material:0x98ae28> material is #<Sketchup::Material:0x98ae28> onElementModified: #<Sketchup::Face:0x98b680> material is #<Sketchup::Material:0x98ae28>

      posted in Developers' Forum
      K
      kwalkerman
    • RE: EntitiesObserver in SU 2014

      Hi TT,

      I created a simple test code and... Everything worked fine. I am doing more investigation on my actual code and I know that the problem occurs when an entities collection has more than one entities observer. The observers are there to perform different functions, but I can probably move the analysis and execution elsewhere (outside the observer) to avoid whatever internal conflict is occurring.

      If I am able to get a test script to recreate the problem, I'll post it.

      By the way, the problem is not unique to SU 2014.

      Karen

      posted in Developers' Forum
      K
      kwalkerman
    • EntitiesObserver in SU 2014

      I just noticed that in SU 2014, the onElementAdded method from the EntitiesObserver class only fires when a single entity is added to the collection. In the past, it would fire once for each entity added to the collection, even if they were all added at one time. For example, if the rectangle tool was used, the observer would recognize five new elements - one right after the other - four edges and one face. In 2014, the observer does not fire at all when multiple elements are added at once. It does not fire when the rectangle tool is used or when multiple objects are pasted into the collection. Is there any work-around for this?

      Is there any other way to detect new objects in a model - both simple (lines and faces) as well as complex objects such as groups and component instances?

      Thanks!

      posted in Developers' Forum
      K
      kwalkerman