def FacesFromEdge(thisEdge):
AD_edge = thisEdge.SelectableObject() # get an Alibre Design API edge object from the AlibreScript edge Object
AD_faces = AD_edge.Faces # get the faces
theseFaces = [] # empty list
for x in range(0, AD_faces.Count): # loop thru faces
thisFace = Face(AD_faces.Item(x)) # get an AlibreScript face Object from the Alibre Design API face object
theseFaces.append(thisFace) # add to the list
return theseFaces # return the list
assem = CurrentAssembly()
prt = assem.GetPart('New Part (1)<1>')
myEdge = prt.GetEdge('Edge<1>')
myEdgefaces = FacesFromEdge(myEdge)
for myFace in myEdgefaces:
print(myFace)
me too . "jumping" between API and AlibreScript should enable it...I couldn't resist.
options = []
values = []
options.append(['Select edge:', WindowsInputTypes.Edge, None]) # 0
values = Windows().OptionsDialog('Select an Edge', options, 180)
if values == None:
print 'Canceled'
sys.exit()
#print dir(values[0]),("\n")#prints a list of all attributes and methods of the selected edge object...
mySelectedEdge = values[0].SelectableObject()
myEdgeFaces = mySelectedEdge.Faces
for x in range(myEdgeFaces.Count):
print Face(myEdgeFaces.Item(x)).Name
My function does the same thing and works for assemblies and parts too. Everything outside the function was just an example usage.me too . "jumping" between API and AlibreScript should enable it...
So i got to the following:
runs in parts as well in assemblies...Python:options = [] values = [] options.append(['Select edge:', WindowsInputTypes.Edge, None]) # 0 values = Windows().OptionsDialog('Select an Edge', options, 180) if values == None: print 'Canceled' sys.exit() #print dir(values[0]),("\n")#prints a list of all attributes and methods of the selected edge object... mySelectedEdge = values[0].SelectableObject() myEdgeFaces = mySelectedEdge.Faces for x in range(myEdgeFaces.Count): print Face(myEdgeFaces.Item(x)).Name
Regards
Stefan
def GetFacesFromEdge(Prt, Ege):
Faces = []
PartEdge = [[Ege.Vertices[0].X, Ege.Vertices[0].Y, Ege.Vertices[0].Z], [Ege.Vertices[1].X, Ege.Vertices[1].Y, Ege.Vertices[1].Z]]
for Fce in Prt.Faces:
for Edg in Fce.GetEdges():
EdgeVertices = Edg.GetVertices()
V1 = [EdgeVertices[0].X, EdgeVertices[0].Y, EdgeVertices[0].Z]
V2 = [EdgeVertices[1].X, EdgeVertices[1].Y, EdgeVertices[1].Z]
if ((PointsAreEqual(V1, PartEdge[0]) and PointsAreEqual(V2, PartEdge[1])) or
(PointsAreEqual(V2, PartEdge[0]) and PointsAreEqual(V1, PartEdge[1]))):
Faces.append(Fce)
return Faces
have you tried it recently?Sadly, measuring the distance between faces of different parts is not implemented
win = Windows()
ca = CurrentAssembly()
options = []
values = []
options.append(['Select face 1' , WindowsInputTypes.Face , None])
options.append(['Select face 2' , WindowsInputTypes.Face , None])
values = win.OptionsDialog( 'Select Faces to measure distance', options , 250 )
if values == None:
sys.exit('Script Aborted')
if values[0].IsParallel(values[1]):
win.InfoDialog("Distance is: "+str(values[0].DistanceTo(values[1])),"Measurement Info")
else:
win.InfoDialog("Faces are not parallel...","Measurement Info")