The Prototype Object

When I am trying to get a component's expressions I have to call


myComponent.Prototype.OwningPart

to get the correct BasePart that has access to the expressions.




Consequently, if I call just myComponent.OwningPart my code will crash when I try to call Expressions.findObject("Expression_Name").



What is this prototype object and how does it just seem to make it work?

The "prototype" of a component is the part file from which the component was created. The "prototype" of an object occurrence is the object (in the prototype part file) from which it is derived.

You can look up these terms in the NX documentation. The SNAP Getting Started guide has a whole chapter that explains these concepts.

Which chapter(s) were you referring to? Thanks for the description.

NX 8.5
NX 9.0

In the NX9 docs and later, Assemblies concepts are covered in Chapter 11 of the SNAP Getting Started guide. I see now that you are using NX 8.5, though.

The syntax: myComponent.OwningPart will return the assembly file because the assembly owns the components. The code then errors out because it is looking in the wrong file for the expressions. You must use the .Prototype syntax to get back to the part file the component is derived from as mentioned above.

I remember seeing a discussion about part vs component vs occurrence in a pdf file; I think it was a draft document posted to the old GTAC programming forum by one of the SNAP developers. None of the attachments made the trip to the new forum (but they are working on restoring them). I thought I had stashed a copy somewhere, if I find it, I'll post it.

I have that document. It's almost the same as the chapter from the SNAP guide that I mentioned. How/where do I upload it ??

I don't currently support an upload function. If you email me a copy, I can put in on the site and link to it (info@nxjournaling.com).

Alternately, if you use a service such as dropbox; you can post a direct link to the file.

Hi,
Did you post this document somewhere on the site?
I am now looking for explanation what is relation between part,component and prototype.
It's because I am confused with structure like mybody.OwningComponent.Prototype.OwningPart
Is the component an "occurence" of prototype?
Is the prototype an NX object which is created from Part?
How the above are related to .prt file?

If you have installed the API documentation, you can find the SNAP getting started guide there. Or, if you have a Webkey account with Siemens, you can find the documentation online at their site:
https://docs.plm.automation.siemens.com/data_services/resources/nx/10/nx...

The chapter on Assemblies (chapter 11) has a lot of good information concerning components, prototypes, and occurrences.