Parameter "Consumed by" Property

Parameter "Consumed by" Property

MartinKunz
Contributor Contributor
482 Views
2 Replies
Message 1 of 3

Parameter "Consumed by" Property

MartinKunz
Contributor
Contributor

Hello,

is there a way to directly access the contents of the "Consumed by" field shown in the Parameters Dialog of Inventor through the API?

 

I implemented a function* that finds the information indirectly by searching the PartComponentDefinition or AssemblyComponentDefinition of the document in question, but that function is relatively slow when we call it for all Parameters of a document, so I was wondering if there is a Property I overlooked (perhaps a hidden Property or Attribute?) that would directly return the information.

 

The existing solution works all right, but it's a performance bottleneck - the "Consumed by" field takes much longer to query than all the other properties of the Parameters combined. So it would be great if there is a simple shortcut to directly get the "Consumed by" string that is shown in the Parameters dlg without searching through the multiple different collections in the ComponentDefinition to obtain the information manually.

 

 

*The function I'm using iterates the .Dependents of the Parameter object,  the Sketches of the Part or Assembly (to compare if one of the Parameters used by the Dimensions equals the search parameter), the Features (comparing if a FeatureDimension uses the search Parameter) and the WorkPoints, WorkAxes and WorkPlanes (checking if one of the items in the DrivenBy collection references our Parameter); when called for an Assembly, we also check the different types of Constraints to find out if its Distance/Offset/Angle property references our Parameter and the OccurrencePatterns to find out if AngleOffset or ElementCount (for CircularOccurrencePattern) or the RowCount/RowOffset/ColumnCount/ColumnOffset (for RectangularOccurrencePattern) is our Parameter.

0 Likes
483 Views
2 Replies
Replies (2)
Message 2 of 3

WCrihfield
Mentor
Mentor

I don't know of any major shortcut method that would make a world of difference, because iterating the Parameter.Dependents is the only main process I know of.  I guess it depends on how your Function is processing everything, and how efficiently it is designed/coded.  Are you checking the 'TypeOf' or 'TypeName' or '.Type' (ObjectTypeEnum) of each object in that dependents collection first, then using something like a Select Case statement to determine how to deal with it?  If the code is not proprietary or anything similar, could you post it here as an attached text file for inspection/testing?  Maybe two (or more) heads will be better than one, when thinking about the most efficient process flow to use.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 3

MartinKunz
Contributor
Contributor

thank you for the reply and for your offer to help - and sorry for the delayed response. The code may end up being used in a commercial product, so i'd rather not publish it.

 

The main problem i'm facing in this function is that the .Dependents collection only contains other Parameter objects that depend on this Parameter, but not the sketches, features, constraints or patterns that use the parameter. 

 

a lightweight solution that only cares about the other Parameters and only iterates the .Dependents would probably have decent performance, but in order to replicate the functionality of the "Consumed By" field, it just takes a lot more effort since you basically have to search them backwards (check all features to find out if one of them references the Parameter etc.)

 

There's probably no way to significantly speed that up for a single Parameter, but since our function needs to find the consumers of all parameters there is some potential for optimization.

0 Likes