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: 

Find in window

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
alexXMC9K
440 Views, 4 Replies

Find in window

Hello,

 

I've written a BOM addon as none of the existing one's i found so far did quite what i wanted ( or weren't free)

It's palette based, so you make a selection and it displays the nominal dimensions of the parts in a table (as in screenshot) from there you either select them all or a subset to export as a pdf / csv etc.

 

I want to add a feature which allows the user to click on a zoom icon in the palette, ad have the related component activated and zoomed to so that I can double check my selection and add instance specific info, like grain direction etc. It seems likely that there is a python equivalent to 'find in window' but i can't find it - apologies if it's obvious and i've missed it!

I've attached a screenshot of what I'm working on, not that it's necessarily helpful..

 

Thanks,

 

Alex

4 REPLIES 4
Message 2 of 5
goyals
in reply to: alexXMC9K

I am sorry to say Find In Window functionality is not exposed through API.



Shyam Goyal
Sr. Software Dev. Manager
Message 3 of 5
p.seem
in reply to: goyals

goyals,

That doesn't mean we give up! 

 

Alex,

Brian had a nice sample of API script that controls the camera viewpoint here.  He sets it based on some selected points, but it seems like a good place to start.  You'd need to do the all the work of determining (presumably based on your occurence's location and bounding box) but I think in this case the API gives you all the tools you need to reproduce their 'Find in Window' behavior.

Message 4 of 5
BrianEkins
in reply to: p.seem

Both of the answers so far are correct; Find in Window isn't directly supported by the API and there is enough functionality in the API that you can write the equivalent.

 

However, there is another solution.  Because the Find in Window command is a simple command and doesn't have a dialog or require any input besides the current selection, you can use the API to select the item you want to show and then execute the Find in Window command.  Below is an example where I use the first occurrence but it can be any object that works with the Find in Window command.

def run(context):
    try:
        app = adsk.core.Application.get()
        ui = app.userInterface
        des = adsk.fusion.Design.cast(app.activeProduct)
        root = des.rootComponent

        # Get the first occurrence in the root component.
        occ = root.occurrences.item(0)

        # Clear all current selections.
        ui.activeSelections.clear()
        
        # Select the occurrence.
        ui.activeSelections.add(occ)
        
        # Get the "Find in Window" command.
        findCmd = ui.commandDefinitions.itemById('FindInWindow')
        
        # Execute the command.
        findCmd.execute()
    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

mand.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
Message 5 of 5
alexXMC9K
in reply to: BrianEkins

Works like a charm! Thank you very much. 

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