How to change document parameters in .ipt file using VBA code

How to change document parameters in .ipt file using VBA code

Anonymous
Not applicable
773 Views
4 Replies
Message 1 of 5

How to change document parameters in .ipt file using VBA code

Anonymous
Not applicable

 

Hi!

 

I am looking for a way to change the document settings of an .ipt file with a VBA code. In the Modeling tab of document settings, I would like to programmatically ively Used in Assembly box.

 

Capture.PNG

 

Best regards,

 

HPL

0 Likes
774 Views
4 Replies
Replies (4)
Message 2 of 5

johnsonshiue
Community Manager
Community Manager

Hi! I think it should be doable. All document settings and application settings should be accessible through API. Some API experts here should be able to help. I do have a question regarding why you need to reset the flag. The flag tells Inventor that this particular part is adaptive within the context of an assembly. Adaptive relationship is context sensitive. The flag helps keeps the context so that the part would not be adaptive in another assembly leading to confusion. I would like to understand why you need to reset the flag and for what purpose.

Many thanks!

 



Johnson Shiue (johnson.shiue@autodesk.com)
Software Test Engineer
0 Likes
Message 3 of 5

Anonymous
Not applicable

Hi M. Shiue

 

Thanks for your answer!

 

I have to insert steel bars in an .IAM and their length have to change so the bars can follow specific curves.  Since I have 100 parts to draw, I want to program this step in a VBA code so I do not have to insert each bar one at the time. I tried to use iCopy, but it does not fit very well to my application.

 

In my VBA code, I copy a first adaptive bar, then I rename it. When I do the copy, the new bar looses it adaptivity, so I try to put it back but I can't because the box stays checked. If I manually uncheck the box, I can have the adaptivity back. So I want my VBA code to do this step automatically.

 

Thanks a lot,

 

HPL

 
 
0 Likes
Message 4 of 5

Anonymous
Not applicable

 

 
0 Likes
Message 5 of 5

Anonymous
Not applicable

The VBA code for unchecked Adaptively Used in Assembly box is :

 

        ...       

 

        Dim copie_composant As ComponentOccurrence        

        Dim fichier_copie_composant As Document

 

        ...

 

        Set fichier_copie_composant = copie_composant.definition.Document   

        fichier_copie_composant.ModelingSettings.AdaptivelyUsedInAssembly = False

 

And then you can put the Adaptivity back with:

 

         copie_composant.Adaptive = True

 

Please note that you have to set the assembly and then you have to insert the .ipt  (in my code it is "copie_composant") to have a ComponentOccurence.

 

Best regards

 

HPL

 

 

 

 

 

0 Likes