
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi!
My current Python script prompts a user to select a face, saves these faces into a variable. Later on, I would like to get coordinates of the vertices of this face and it seems like `vertices` is a property of BRepFace [https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-5e31b969-2cdf-4793-ab06-3dee7de19378]. However, when I run the code I keep getting attribute error.
Wondering what is an issue here? Find a script below.
(side note: before that I had a body being selected by a script and then I could get vertices coordinates using this code `rootComp.bRepBodies.item(body_idx).faces.item(face_idx).vertices.item(vertix_idx).geometry.x`. Why is it an issue now when user selects a face himself?)
def run(context):
ui = None
try:
# set up:
app = adsk.core.Application.get()
ui = app.userInterface
design = app.activeProduct
# ensuring that there is model built & active:
if not design:
ui.messageBox('No active Fusion design', 'No Design')
return
# Get the root component of the active design:
rootComp = design.rootComponent
holes = rootComp.features.holeFeatures
unsafe_faces = [] # [face_ref, which_side, length_x, width_y, height_z] storage for reference to objects
### -- Prompting a user to select faces that need to be modified
user_answer = ui.inputBox("Do you want to specify faces where holes will be placed? Type 'yes', if so \
\n Otherwise, if you want the program to determine faces for you, type 'no'. \
\n Please select 'yes' for now [work in progress for 'no']")
# TODO:
# if str(user_answer[0]).strip().lower() == 'no':
# TODO: choose the faces for user
selected_face = ui.selectEntity("Please, choose faces which need better heat dissipation.\
\n If needed, choose all the faces under the upper case.", 'PlanarFaces')
ui.messageBox(str(selected_face.vertices.count) # ATTRIBUTE ERROR
unsafe_faces.append([selected_face])
Solved! Go to Solution.