Community
Fusion API and Scripts
Got a new add-in to share? Need something specialized to be scripted? Ask questions or share what you’ve discovered with the community.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Selection Input for Sketch

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
kulkarniyh12.mech
838 Views, 3 Replies

Selection Input for Sketch

I am writing an Extrude like command called FACE (Sheet Metal feature), which takes sketch as input. Following is what I have written, but it does not select the sketch.

class FaceCommandCreatedEventHandlerPanel(adsk.core.CommandCreatedEventHandler):
    def __init__(self):
        super().__init__() 
    def notify(self, args):
        try:
            cmd = args.command
            onFaceExecute = FaceCommandExecuteHandler()
            cmd.execute.add(onFaceExecute)

            onFaceInputChanged = FaceInputChangedHandler()
            cmd.inputChanged.add(onFaceInputChanged)
            
            onFaceValidateInput = FaceValidateInputHandler()
            cmd.validateInputs.add(onFaceValidateInput)
    
            # keep the handler referenced beyond this function
            handlers.append(onFaceExecute)
            handlers.append(onFaceInputChanged)
            #handlers.append(onFaceValidateInput)

            #define the inputs
            # Sketch Selection
            inputs = cmd.commandInputs
            i1 = inputs.addSelectionInput('FaceSketchSelection', 'Sketch', 'Please select an sketch') # 'PlanarSketch'
            i1.addSelectionFilter('Sketches');
        except:
            if ui:
                ui.messageBox(('Panel command created failed: {}').format(traceback.format_exc()))

 

 

Picture:

 

SketchSelectionNotWorking.png

 

What am I missing?

3 REPLIES 3
Message 2 of 4

Hi kulkarniyh12.mech,

 

Fusion does not actually support selection of a Sketch in the graphics window, only browser selection of a Sketch object is supported.  This is not entirely obvious, because normally when you think you're selecting a Sketch in the graphics window, what you're actually selecting is the Sketch profile.  If you hide the sketch profile (use context menu on the sketch object in the browser to access Hide/Show Profiles command) you'll notice you cannot directly select the Sketch in the graphics window (you can select it's curves/geometry). The API works just like the UI, so if you filter for "Sketches" you'll have to select a sketch from the browser if a Sketch object is actually what you need.

I assume however (and it's usually note wise to do so but I will anyway) that what you are really after is the Profile of the Sketch, and that is something that can be selected from the graphics window.  If my assumption is correct, then use the "Profiles" filter instead of the "Sketches" filter and you'll be on your way.

i1.addSelectionFilter('Profiles');

 

DaVeR
Message 3 of 4

Use of 'Profiles' is fine with me. Your suggestion worked. Thanks a lot.

Message 4 of 4

Hi 

I doing something where I need to select a sketch, how can I use your approach 

its not clear to me as you define the cmd based on variable args in the function

not very proficient with python so excuse lack of knowledge of args 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report