VBA failure Inventor 2023: AddByComponentDefinition will fails if the the ComponentDefinition object has Model States

VBA failure Inventor 2023: AddByComponentDefinition will fails if the the ComponentDefinition object has Model States

christoph_stumpf
Contributor Contributor
295 Views
3 Replies
Message 1 of 4

VBA failure Inventor 2023: AddByComponentDefinition will fails if the the ComponentDefinition object has Model States

christoph_stumpf
Contributor
Contributor

Who could help me,

if you want to add an occurence in an Assembly an the "newdoc.ComponentDefinition" Object has Model States the following code get an error...

 

activeASS.ComponentDefinition.Occurrences.AddByComponentDefinition(newdoc.ComponentDefinition, oPositionMatrix)

 

The code work always if the "newdoc.ComponentDefinition" has no Model States. (Inventor 2023)

0 Likes
296 Views
3 Replies
Replies (3)
Message 2 of 4

JelteDeJong
Mentor
Mentor

I expect that your object "activeASS" is not the factory document. (But a model state document). You might want to have a look at this post "Working with PropertySets and Model States"

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes
Message 3 of 4

christoph_stumpf
Contributor
Contributor

Hello,

the activeASS is not a factory document, is an standard assembly document.

In this document i will place a new part document which is an template. This template has Model states.

 

The routine run's since years, but now i have added to the template model states an then i get the error in VBA.

0 Likes
Message 4 of 4

christoph_stumpf
Contributor
Contributor

No this don't help me.

The only thing i will do is to add an template File into an Assembly document, via AddByComponentDefinition.

 

It works since years without problems. But i have add to the template Model State definition. After that it don't work.

 

I don't add properties or other thinks in the moment, i only want to add the template.... so your link is not the solution.

0 Likes