Trouble finding faces
-
I am using an If else statement, I got it to work earlier in the code, but now I am having an issue grouping a new entity and finding it's face, it has to do with adding an arc and not adding an arc.
How would one name a group and find the faces in this situation?

ents=Sketchup.active_model.active_entities prompts = ["Stair Width", "Travel","Tread Thickness","Total Height","Riser Thickness","Stringer Width","Stringer Thickness","Top Hanger Thickness","Customer","Customer Address","Top Hanger Nose","Round Nose","Flight","No Nose"] defaults = [36.0,51.5,1.5,46.5,0.5,11.25,1.25,0.5,"My Builder", "234 Jimmys street","Yes","Yes","Main","Yes"] list=["","","","","","","","","","", "Yes|No","Yes|No","Main","Yes|No"] input = UI.inputbox prompts, defaults,list, "Stair Info" a,b,c,d,e,f,g,h,i,j,k,l,m,n=input cst=i.to_s adr=j.to_s ent = Sketchup.active_model.entities tr=(d/8.0).ceil rise=d/tr run=((b-(1+h))/(tr-1)) wdth=a-2.5 prompts = ["Stair Width", "Number if Rises","Height","Travel","Hanger"] defaults = [36.0,tr,d,b,h] list=[""] input = UI.inputbox prompts, defaults,list, "Rise and Run" wth,rs,b,d,h=input cst=i.to_s adr=j.to_s ent = Sketchup.active_model.entities l rise=b/rs run=((d-(1+h))/(rs-1)) #---------Clear All Sketchup.active_model.entities.clear! #----------------Make 1st tread ent.add_line [0,(run+1)+0*run-1.5,rise-c], [0,(1.5+0*run)-1.5,rise-c] ent.add_line [0,1.5+0*run-1.5,rise-c+0.1875], [0,1.5+0*run-1.5,rise-c] ent.add_line [0,1.5+0*run-1.5,rise-c+0.1875], [0,1+0*run-1.5,rise-c+0.1875] ent.add_line [0,1+0*run-1.5,rise-c+0.1875], [0,1+0*run-1.5,rise-c] #Nose Yes/No<<<<< if n=="Yes" ns=1 else ns=0 end puts ns puts d #End add nose<<< #ROUND Nose Yes/No<<<<<< if l=="Yes" puts "Round Nose" #add arc<<<<<< edg = ent.add_line [0,1+0*run-1.5,rise-c],[0,e+0*run-1.5,rise-c];vrt1=edg.end ent.add_arc [0,0.5+0*run-1.5,-c/2.0+(rise)],[0,0,-1],[-1,0,0],c/2.0,0,180.degrees,12 edg = ent.add_line [0,1+run-1.5,rise],[0,0.5-1.5,rise];vrt2=edg.start #end Add Arc<<<<< else edg = ent.add_line [0,1+0*run-(1+0.5),rise-c],[0,e+0*run-(ns+1),rise-c] edg = ent.add_line [0,e+0*run-(ns+1),rise-c],[0,e+0*run-(ns+1),rise] edg = ent.add_line [0,e+0*run-(ns+1),rise],[0,(run+1)+0*run-1.5,rise] puts "SQUARE NOSE" end edg=ent.add_line [0,1+run-1.5,rise],[0,1+run-1.5,rise-c] edg.find_faces; face=edg.faces[0] face.pushpull wdth if l=="Yes" edgs=vrt1.edges.reject!{|e| e.length<wdth};edgs[0].soft=true edgs=vrt2.edges.reject!{|e| e.length<wdth};edgs[0].soft=true else end group1 = ent.add_group face.all_connected ;group1.name="Tread" group1.description="Tread" for i in 1..tr-2 group2 = group1.copy tran = Geom;;Transformation.translation [0, run*i, rise*i] group2.transform! tran end ents=Sketchup.active_model.active_entities #---Good group = ent.add_group(); group.name="Bottom riser" ent2 = group.entities pts = [] pts[0] = [0, 0, 0] pts[1] = [0,-e,0] pts[2] = [0, -e,rise-c+0.1875] pts[3] = [0, 0, rise-c+0.1875] # Add the face to the entities in the model face = ent2.add_face pts face.pushpull wdth group.description = "Bottom riser" #---good group = ent.add_group(); group.name="Riser" ent3 = group.entities pts = [] pts[0] = [0, run, rise-c] pts[1] = [0,run-e,rise-c] pts[2] = [0, run-e,2*rise-c+0.1875] pts[3] = [0, run, 2*rise-c+0.1875] # Add the face to the entities in the model face = ent3.add_face pts face.pushpull wdth group.description = "Riser" for i in 1..rs-3 group2 = group.copy tran = Geom;;Transformation.translation [0, run*i, rise*i] group2.transform! tran end #----good #<<<<<<Top Hanger group = ent.add_group(); group.name="Top riser" ent5 = group.entities ent5.add_line [0,b+3,b-c], [0,b+3,b-15] ent5.add_line [0,b+3,b-15], [0,b+3+h,b-15] ent5.add_line [0,b+3+h,b-15], [0,b+3+h,b] #ROUND Nose Yes/No<<<<<< if l=="Yes" puts "top hanger round nose" #add arc<<<<<< edg = ent5.add_line [0,b+3,b-c], [0,b+3-0.5,b-c] ;vrt1=edg.end ent5.add_arc [0,b+3-0.5,b-(c/2)],[0,0,b+3-1],[-1,0,0],-c/2.0,0,180.degrees,12 edg = ent5.add_line [0,b+3+h,b], [0,b+2.5,b];vrt2=edg.start #end Add Arc<<<<< else puts "top hanger square nose" ent5.add_line [0,b+3,b-c], [0,b+3-1,b-c] ent5.add_line [0,b+3-1,b-c], [0,b+3-1,b] ent5.add_line [0,b+3-1,b] , [0,b+3+h,b] end #add the face to the entities in the model edg.find_faces; face=edg.faces[0] face.pushpull -wdth -
@davesexcel said:
I am using an If else statement, I got it to work earlier in the code, but now I am having an issue grouping a new entity and finding it's face, it has to do with adding an arc and not adding an arc.
It seems to me that you define 'edg' twice if l=="Yes" but don't define it at all if l=='No'.
#ROUND Nose Yes/No<<<<<< if l=="Yes" puts "top hanger round nose" #add arc<<<<<< edg = ent5.add_line [0,b+3,b-c], [0,b+3-0.5,b-c] ;vrt1=edg.end ent5.add_arc [0,b+3-0.5,b-(c/2)],[0,0,b+3-1],[-1,0,0],-c/2.0,0,180.degrees,12 edg = ent5.add_line [0,b+3+h,b], [0,b+2.5,b];vrt2=edg.start #end Add Arc<<<<< else puts "top hanger square nose" edg=ent5.add_line [0,b+3,b-c], [0,b+3-1,b-c]#<<<< edg ent5.add_line [0,b+3-1,b-c], [0,b+3-1,b] ent5.add_line [0,b+3-1,b] , [0,b+3+h,b] end #add the face to the entities in the model edg.find_faces; face=edg.faces[0] face.pushpull wdth

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 LoginAdvertisement