Find in window

Find in window

Anonymous
1,073 Views
4 Replies
Message 1 of 5

Find in window

Anonymous
Not applicable

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

0 Likes
Accepted solutions (1)
1,074 Views
4 Replies
Replies (4)
Message 2 of 5

goyals
Autodesk
Autodesk

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



Shyam Goyal
Sr. Software Dev. Manager
0 Likes
Message 3 of 5

p.seem
Advocate
Advocate

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
Mentor
Mentor
Accepted solution

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

Anonymous
Not applicable

Works like a charm! Thank you very much. 

0 Likes