Script won't find face
-
I have this one scripts,
UI.menu("PlugIns").add_item("Draw Riser") { draw_riser } def draw_riser prompts = ["length", "Run","height","Rise","Total Rises","Riser Thickness"] defaults = [36.0,10.0,1.0,7.75,7,0.5] input = UI.inputbox prompts, defaults, "Risers." a,b,c,d,e,f=input ent = Sketchup.active_model.entities #---------Clear All #Sketchup.active_model.entities.clear! #----------------Make 1st Riser ent.add_line [0,0,d-c+0.1875], [0,0,0] ent.add_line [0,-0.5,d-c+0.1875], [0,-0.5,0] ent.add_line [0,0,0], [0,-0.5,0] ent.add_line [0,0,d-c+0.1875], [0,-0.5,d-c+0.1875] #edg.find_faces; face=edg.faces[0] #face.pushpull a ##group5 = ent.add_group face.all_connected #----------------Make rest of Risers ent.add_line [0,b,2*d-c+0.1875], [0,b,d-c] ent.add_line [0,-0.5+b,2*d-c+0.1875], [0,-0.5+b,d-c] ent.add_line [0,b,d-c], [0,-0.5+b,d-c] ent.add_line [0,b,2*d-c+0.1875], [0,-0.5+b,2*d-c+0.1875] # edg.find_faces; face=edg.faces[0] #face.pushpull a #group3 = ent.add_group face.all_connected #for i in 1..e-2 # group5 = group4.copy # tran = Geom;;Transformation.translation [0, b*i, d*i] #group5.transform! tran #end end
Im having issues getting the code to make the faces and then pushpull.
My idea is to make the 1st riser a group on it's own, then make the second riser a group and copy it up.
Thanks
-
Do not add the edges to the model entities, they will intersect with the model.
-
Create an empty group, and immediately add a cpoint into it (to keep SU garbage collection from deleting it.)
-
then add the edges to the group's entities collection
-
then do find_faces on the edges inside the group and the face should added to the group's entities.
-
then do the push pull
-
delete the temp cpoint
-
then copy the group
-
-
To expand that point...
ent = Sketchup.active_model.entities **group = ent.add_group() ent = group.entities**
Add the two 'BOLD' lines after the
ent =
Then everything is inside 'group
', which you can 'name' etc as you wish... -
Thank you,
That worked.
Advertisement