Get pattern component based on its position/coordinates

Programming and macros
Kjara
Posts: 21
Joined: Mon Jul 19, 2021 2:49 am
Answers: 0
x 1

Get pattern component based on its position/coordinates

Unread post by Kjara »

I have some component pattern (e.g. ILocalLinearPatternFeatureData, ILocalCircularPatternFeatureData; there are more).

I want to reference a certain component in that pattern in a way that I can
- determine if it currently exists based on the current instances in all possible dicrections;
- if it exists, get its IComponent2 object (in order to manipulate it).

That reference must be robust. That means: No matter how often I change the values of the instance dimensions, I should always get the component (if it exists).

Is there a way to do this?

To clarify:
Each component pattern is an IComponent2, and thus has a GetID(). The GetID() is generally a good way to reference components because it does not contain any data about the underlying file or the position in the feature tree or the component name or such. It never changes, so it is quite robust. But for pattern components it does not work: Modifying the values of the instance dimensions leads to REMOVAL and ADDING of components, depending on whether the instance value gets smaller or larger. So if we store the GetID() of some pattern component (e.g. value 116), then make the instance values smaller so that the component gets removed, then make the instance values larger, NEW components are added with NEW GetID()s. There is no guarantee that after that, a component of the same id (116) will exist; and even if a component of that id exists, there is no guarantee that is in the same position as the old one was before. So the GetID() just does not work here.

The property SkippedItemArray, which most component patterns have, suggests that internally each pattern component is referenced by coordinates (one or two):
pattern skipped instances.png
As far as I can tell, the same coordinates always give the same position, no matter what the pattern component's GetID() is. So these coordinates would be the perfect reference for a pattern component. But: I could not find any API method that gives me a pattern component for given coordinates.
Post Reply