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: 

Select a Rectangle by using ui.selectEntity

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
matthias.reissmann
729 Views, 2 Replies

Select a Rectangle by using ui.selectEntity

Hi!

I'm Matthias and I'm about starting to use the Fusion API to script some simple reoccurring tasks. Sorry for some 'stupid' questions but I didn't find any solution on the web.

 

What I try is to make a user selection of an existing rectangle in a sketch. With this rectangle I will do some further processing. What I wrote is:

 

 

        ui  = app.userInterface
        selectedItem1 = ui.selectEntity("Select the rectangle", "SketchCurves")

 

Since the filter for selectEntity doesn't have an entry like 'SketchRectangle' I used SketchCurves instead, but with this filter I can only select one line of the rectangle and not the whole rectangle.

Any help would be really appreciate. By the way: is there a good link which shows some example code how to use user selection with the API?

 

Many thanks in progress!

Matthias

 

 

2 REPLIES 2
Message 2 of 3
liujac
in reply to: matthias.reissmann

Hi,

 

UserInterface.selectEntity only can select one entity. Sketch Rectangle is not a type of entity, it is a set of sketch lines. You might want to select the closed area of the Sketch Rectangle. The closed area is a profile.

selectedItem1 = ui.selectEntity("Select the profle", "Profiles")

If you did want to select sketch lines of the sketch rectangle, you need to find the connected curves and add them to active selections.

        selectedItem1 = ui.selectEntity("Select the rectangle", "SketchCurves")
        skCurve = adsk.fusion.SketchCurve.cast(selectedItem1.entity)
        sketch = skCurve.parentSketch
        curves = sketch.findConnectedCurves(skCurve)
        for curve in curves:
            ui.activeSelections.add(curve)

Regards,

Jack

Message 3 of 3
matthias.reissmann
in reply to: liujac

Hi Jack,

 

thanks for the answer. I will go with the 'profile' selection type.

 

Matthias

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