sketchucation logo sketchucation
    • Login
    1. Home
    2. chochmah
    3. Posts
    Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
    πŸ«› Lightbeans Update | Metallic and Roughness auto-applied in SketchUp 2025+ Download
    C
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 4
    • Groups 1

    Posts

    Recent Best Controversial
    • RE: Intersect two Component Instances

      Thank you. That solved the last Problem with the intersect.

      you guys have been very helpful@TIG,sdmitch Thanks a thousand

      posted in Developers' Forum
      C
      chochmah
    • RE: Intersect two Component Instances

      Thank you! This works indeed. I just had to remove the one ".inverse".

          intersection_edges = entities.intersect_with(true, tr, instance_bulkhead.definition.entities, instance_bulkhead.transformation, true, [instance_body, instance_bulkhead])
      
      

      The one remaining problem is now that there are usually more than two entities and this intersects all of them with the instance_body including the instance_body itself. Do you have a quick tip how to restrict the intersect to the two objects instance_body and instance_bulkhead?

      Thank you very much for your help, it's much appreciated

      posted in Developers' Forum
      C
      chochmah
    • RE: Intersect two Component Instances

      @tig said:

      First off please don't use $ variables - one day they'll clash with other's code and cause disasters... use @ ones if your code spans 'def' methods...
      Also calling your component/instance 'model' is just confusing as that's normally used for 'the model' itself ! And 'plane' refers to something that a face has... πŸ˜’
      Make references to the two 'containers' instead of their entities !
      Say @xmodel and @xplane - we can deal with the entities later...
      Try messing around with the .inverse methods if the intersection id not where it's required...

      Thanks for the quick reply.
      I replaces the global variables and renamed the instances.

      model = Sketchup.active_model
      entities = model.entities
      
      instance_body=0
      instance_bulkhead=0
      
      entities.each do |s|
       if s.definition.name=="Model"
        instance_body=s;
       end
       if s.definition.name=="BPC"
        instance_bulkhead=s
       end
      end
      
      intersection_edges = Sketchup.active_model.active_entities.intersect_with(true, instance_bulkhead.transformation.inverse , instance_bulkhead.definition.entities, instance_bulkhead.transformation.inverse , true, [instance_body, instance_bulkhead])
      
      

      I tried every possible combination of inverse and non-inverse but there's always strange stuff happening. It does only work if both instances are not transformed at all so I guess it must have something to do with the transforms.

      Thank you very much

      http://666kb.com/i/c6z16r4fzyihtjhbr.jpg

      The lines are the intersection_edges

      posted in Developers' Forum
      C
      chochmah
    • Intersect two Component Instances

      Hi Forum,
      I'm going crazy trying to intersect two component instances.

      I want to intersect a instance of the component Model and a instance of the component Plane and store the intersecting edges in intersection_edges in the Plane Component. I fail miserably probably because I don't really understand how the transformations work on instances. Any Help would be really great, I already spend more than 2 hours trying to get this to work.

      entities.each do |s|
       if s.definition.name=="Model"
        $model_tr = s.transformation
        $entities_model=s.definition.entities
       end
       if s.definition.name=="Plane"
        $plane_tr = s.transformation
        $entities_plane=s.definition.entities
       end
      end
      
      intersection_edges = $entities_plane.intersect_with(false,$model_tr.inverse ,$entities_plane,$plane_tr,false,$entities_model.collect)
      

      Thank you very much!

      posted in Developers' Forum
      C
      chochmah
    • 1 / 1