Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am working on a python add in that will project user selected edges to a sketch on a user selected face, however creating a sketch on said face seems to wipe out the values in my edge selection. You can see my stripped down test code below which I have been testing with a simple cube.
It seems like this issue came about with the latest updates to Fusion as this was working for me earlier this week.
# This event handler is called when the user clicks the OK button in the command dialog or
# is immediately called after the created event not command inputs were created for the dialog.
def command_execute(args: adsk.core.CommandEventArgs):
# General logging for debug.
futil.log(f'{CMD_NAME} Command Execute Event')
# Get a reference to your command's inputs.
inputs = args.command.commandInputs
edges = inputs.itemById('edge_Selection') # User selected edges from selectionInput
top_face = inputs.itemById('face_Selection').selection(0).entity # User selected face from selectionInput
# Output edge count to the log
futil.log(f'Edges Qty: {edges.selectionCount}')
# Create collection of edges
edge_count1 = edges.selectionCount
futil.log(f'Edge Count Variable 1= {edge_count1}')
futil.log(f'Edge Selection Count = {edges.selectionCount}')
# Create sketch on top surface plane to house outline profile
sk_outline = root.sketches.addWithoutEdges(top_face)
sk_outline.name = 'Outline Sketch'
# DEBUG Check edge count again
edge_count2 = edges.selectionCount
futil.log(f'Edge Count Variable 1 = {edge_count1}')
futil.log(f'Edge Count Variable 2 = {edge_count2}')
futil.log(f'Edge Selection Count = {edges.selectionCount}')
# Get all edges from edges selection input
edge_coll = adsk.core.ObjectCollection.create()
i = 0
edge_count3 = edges.selectionCount
futil.log(f'Edges Qty = {edges.selectionCount}')
futil.log(f'Edge Count Variable 3 = {edge_count3}')
while i < edge_count1:
edge_coll.add(edges.selection(i))
futil.log(str(i))
i += 1
Solved! Go to Solution.