View Representations

View Representations

zikmund
Contributor Contributor
461 Views
5 Replies
Message 1 of 6

View Representations

zikmund
Contributor
Contributor

Hi,

I'm trying to put together some code for automatic view representations.

I have part with no view representations, only Master. I want to create 17 new representations and set up each representation appearance correctly from my appearance library.

My code sets all seventeen reps, asigns colours and if I put this part into assembly, I can switch representations of it easily in right click menu.

My problem is when I upload it into content center. When I add the part from content center into the assembly, these representations are there, but colour schemes are not working.

 

Code bellow is for ACCESSORIES view representation. The same is written for all other 16 (see attached IPT).

 

Dim oPartDoc As PartDocument 
	oPartDoc = ThisApplication.ActiveDocument 
Dim oCompDef As ComponentDefinition
	oCompDef = oPartDoc.ComponentDefinition
Dim oViewRep As DesignViewRepresentation

'Definice 3DCG Appearance Library
Dim oLib As AssetLibrary
	oLib = ThisApplication.AssetLibraries("3DCG_Appearance_Library")
Dim libAsset As Asset
Dim localAsset As Asset 

'[Aktivace reprezentace ACCESSORIES
oViewRep = oCompDef.RepresentationsManager.DesignViewRepresentations.Add("ACCESSORIES")
oCompDef.RepresentationsManager.DesignViewRepresentations.Item("ACCESSORIES").Activate

libAsset = oLib.AppearanceAssets.Item("ACCESSORIES") 
Try  
	localAsset = oPartDoc.Assets.Item("ACCESSORIES") 
Catch 
	localAsset = libAsset.CopyTo(oPartDoc)
End Try
oPartDoc.ActiveAppearance = localAsset
']

Thanks for help.

0 Likes
462 Views
5 Replies
Replies (5)
Message 2 of 6

A.Acheson
Mentor
Mentor

Hi @zikmund 

Have you set the occurrence in the assembly to the correct View Rep and set to associative? If not you will be getting the master View Rep.

 

AAcheson_0-1687324077725.png

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 3 of 6

zikmund
Contributor
Contributor
Hi Alan,

It doesn't matter. The parts inserted from a content center simply don't change the appearance based on set representation. What is strange to me, that normal parts (not uploaded) to content center work perfectly. Also when I create and set all representation manually and send the part to library, it also works.

Milan
0 Likes
Message 4 of 6

WCrihfield
Mentor
Mentor

Hi @zikmund.  I downloaded & opened your part, opened the appearance dialog, and I see that there are currently 18 appearances listed in there.

WCrihfield_0-1687349397896.png

Are those all of the appearances you are trying to use for that component?  The thing about content center stuff is that they become ReadOnly once you publish them into the content center.  So, you can no longer change anything about that file.  Therefore, changing a CC part to another DVR (DesignViewRepresentation) is no longer allowed.  So, if you want to be able to change the appearance of the assembly component representing that CC part in the assembly, you will need to leave the 'associative' setting for that component off, and may have to have those appearances available in the assembly, so you can directly change the appearance of the component, just within the assembly.  It seems to me like you may be attempting to use these for filtering or categorization purposes later.  If that is the case, and you have 2022 or later version of Inventor, you may be able to use something like instance properties (aka: occurrence properties) (Link, Link, Link) within the assembly.

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 5 of 6

zikmund
Contributor
Contributor
Hi @WCrihfield

I always save parts from content center as custom to be able to write into them. However view representations are great because even parts saved in content center folder can be changed visualy - you don't change the part, but change the way how it looks like in assembly.
Again, the strange thing for me is, if I create all view reps in file manualy one by one and define appearance to each, then it works if this part is published to content center and then put into assembly from it.
Thanks.
0 Likes
Message 6 of 6

J-Camper
Advisor
Advisor

@zikmund,

 

What version of Inventor are you using? 

 

I saved your part, edited the rule only to ignore the library as I don't have it, ran the rule to create the view reps, and saved it to the content center.

 

When I place from the content center the View Reps appear to function as intended in 2023.3

0 Likes