sketchucation logo sketchucation
    • Login
    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!
    Urasik Extensions | Lots of new extensions to check out Learn More

    Automate component placement onto TIN

    Scheduled Pinned Locked Moved SketchUp Discussions
    sketchup
    2 Posts 2 Posters 204 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

        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

        With your input, this post could be even better đź’—

        Register Login
        • 1 / 1
        • First post
          Last post
        Buy SketchPlus
        Buy SUbD
        Buy WrapR
        Buy eBook
        Buy Modelur
        Buy Vertex Tools
        Buy SketchCuisine
        Buy FormFonts

        Advertisement