What's new

OptionsDialog to select a feature

Jholt

Member
I would like to use an OptionsDialog window to allow the user to select a specific part feature. However I don't see a feature option in the WindowsInputTypes enum. Doing some digging, I found a Features property of the Part class which is of type list, but it is empty in my part. I can access my feature by name using Part.GetFeature(<name>) just fine.

So my question is: Is there a way to get a list of all the feature names in a part?

If I have this, I can use a WindowsInputTypes.StringList to let the user pick the correct feature.

Thanks,
Jenn
 

Jholt

Member
Stefan (or anyone else who might know)
Is there a way to get a list of the Parameters/Dimensions that drive a sketch? what I mean is when editing a sketch in the normal GUI, there are dimensions (linear, angular etc.) that along with constraints define the geometry of the figures. One can change the value of these dimensions and the sketch updates.

Say I have a reference to a sketch (com.alibre.automation.AlibreSketch) is there a way to get these dimensions in the script and modify them? I see a bunch of ways to add dimensions to a sketch in the API docs but not a lot for finding and modifying existing ones.

Thanks,
Jenn
 

Jholt

Member
Hello Jenn,

you have acces to the EE-Parameter values...
take a look at: https://www.alibreforum.com/forum/index.php?threads/gear-motion.20806/#post-133091

Regards
Stefan

Stefan,
I had found how to access parameters from the EE using Part.Parameters. But I'm not sure how to correlate those with a particular sketch. Part.Parameters gives all the dimensions used in all the sketches, as well as any used to drive reference geometry(as far as I can tell).

From this list of all dimensions, is there a way to filter out only those used in a specific sketch? Something like this (although sketch doesn't actually have a Parameters property):

"""
>>>part = CurrentPart()
>>>sketch = part.GetSketch('mySketch1')
.>>>sketch2 = part.GetSketch('mySketch2')
>>>[p.Name for p in part.Parameters] # all parameters
['D1', 'D2', 'D3']
>>>[p.Name for p in sketch.Parameters] # pseudo-code for desired result, parameters used in sketch
['D2', 'D3']
>>>[p.Name for p in sketch2.Parameters] # pseudo-code for desired result, parameters used in sketch2
['D1']
"""

where D2 and D3 are used in 'mySketch1', and D1 is used in 'mySkethc2'
 

DavidJ

Administrator
Staff member
Parameters are available across the model.

If you want to distinguish them between sketches, you'll have to give them names that help, say

Sk1_D2, Sk2_D2, Sk3_D2 or D2_Sk1, D2_Sk2.... or some other scheme.
 

idslk

Alibre Super User
it "should" be possible to query the following information (using the API...if the property is exposed...):

upload_2020-7-5_12-55-6.png

I haven't tried it yet...

Regards
Stefan
 

Jholt

Member
Parameters are available across the model.

If you want to distinguish them between sketches, you'll have to give them names that help, say

Sk1_D2, Sk2_D2, Sk3_D2 or D2_Sk1, D2_Sk2.... or some other scheme.

David,
I won't be able to change the names of the parameters since I am trying to write a "generic" script. That is, one that can be used on multiple parts without prior knowledge of what is in the part. Basically I am trying to make a script that patterns a feature by duplicating everything used to create that feature, but changing the dimensions according to some function of instance number(currently just a simple step value on one dimension). My plan is the following:

Step 1, query the part and get a list of features. use this list to populate a user interaction window that lets the user select which part they want to pattern. I have this working. (by the way, it would be a nice feature to add to the API to have a "WindowsInputTypes.Feature" option for the Windows.OptionsDialog)

Step2, using the feature, get information about it. The sketch, whether is is an extrude/revolve cut/boss (I am ignoring more complicated things like lofts or helical), what the axis of revolution is(for revolves), and the dimensions used in the sketch. Currently I have succeeded in getting the sketch, and am working on getting the dimensions.

Step 3, in a loop make new sketches for each pattern instance by: saving the initial values of the dimensions(from the pattern leader), modify the pattern leader sketch with the new dimensions for that instance, copy the modified sketch to a new sketch, finally restore the original dimensions. (this is necessary because I have found that when I copy a sketch, the constraints and dimensions are not copied, so all modification has to be done on the original sketch)

Step 4, in a loop go through the generated sketches and apply the appropriate operation: extrude/revolve boss/cut.

Thanks,
Jenn
 

Jholt

Member
it "should" be possible to query the following information (using the API...if the property is exposed...):

View attachment 31091

I haven't tried it yet...

Regards
Stefan

Stefan,
That looks promising. It looks like that ownership information would probably be stored with the Parameter? I can use the python "inspect" module to look a little deeper into the classes and see if anything like that exists, but isn't documented. I'll report back.

Jenn
 
Any of you who have looked at my "Libraries" where Equation Editor values distinguish one Item from another Item will note that I name my Equation Editor Variables as "a0_a0_name" where "a0" represents a "lower case letter" followed by a "number." This works to keep my variables at the "top" of the Equation Editor values list. "Lower Case ASCII" letters have a "lessor value" than "Upper Case ASCII" letters. -- Lew
 

Jholt

Member
I got it. The AlibreX IADSketchInterface has a "Dimensions" property which can be used to get what I want:

>>>[d.Parameter.Name for d in mySketch._Sketch.Dimensions.GetEnumerator()]
['foo', 'D7', 'D5', 'D6']
 
Top