sketchucation logo sketchucation
    • Login
    🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    Automate component placement onto TIN

    Scheduled Pinned Locked Moved SketchUp Discussions
    sketchup
    2 Posts 2 Posters 145 Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Z Offline
      zawisza5
      last edited by

      Hello, I am trying to populate a TIN 3D surface with components. Within each triangle surface I would like two random components( represented by different colored dots in attached picture). Does anyone have any idea of how to populate the TIN more quickly than placing every component by hand. The TIN was imported into sketchup from ArcGIS.


      ImageExample

      1 Reply Last reply Reply Quote 0
      • sdmitchS Offline
        sdmitch
        last edited by

        @zawisza5 said:

        Hello, I am trying to populate a TIN 3D surface with components. Within each triangle surface I would like two random components( represented by different colored dots in attached picture). Does anyone have any idea of how to populate the TIN more quickly than placing every component by hand. The TIN was imported into sketchup from ArcGIS.

        I produced this resultsDots on Face.jpg

        with this code

        
        def placethedots
        
        mod = Sketchup.active_model
        ent = mod.active_entities
        sel = mod.selection
        cdefs = mod.definitions.reject{|cd| cd.group?||cd.image?}
        faces = sel.grep(Sketchup;;Face)
        faces.each{|f|
         tx=0.0;ty=0.0;tz=0.0;
         p=f.outer_loop.vertices.collect{|v|v.position}
         p.each{|v| tx+=v.x;ty+=v.y;tz+=v.z}
         ax=tx/p.length;ay=ty/p.length;az=tz/p.length
         ctr=Geom;;Point3d.new(ax,ay,az);#ent.add_cpoint(c)
         pt1=ctr.offset([-6,6,0])
         cd=cdefs[rand(cdefs.length)]
         ent.add_instance(cd,Geom;;Transformation.new(pt1,f.normal))
         pt2=ctr.offset([6,-6,0])
         cd=cdefs[rand(cdefs.length)]
         ent.add_instance(cd,Geom;;Transformation.new(pt2,f.normal))
        }
        
        end
        
        

        I first created the six component "dots". Selected the faces then executed the code.

        Nothing is worthless, it can always be used as a bad example.

        http://sdmitch.blogspot.com/

        1 Reply Last reply Reply Quote 0
        • 1 / 1
        • First post
          Last post
        Buy SketchPlus
        Buy SUbD
        Buy WrapR
        Buy eBook
        Buy Modelur
        Buy Vertex Tools
        Buy SketchCuisine
        Buy FormFonts

        Advertisement