UpdateFrom​Global for Colors / Appearances

UpdateFrom​Global for Colors / Appearances

Curtis_Waguespack
Consultant Consultant
975 Views
4 Replies
Message 1 of 5

UpdateFrom​Global for Colors / Appearances

Curtis_Waguespack
Consultant
Consultant

I would like to update the current Appearance / Color in a model to match the library, but cannot find an example or anything in the API help to point me to in the correct direction.

 

Does anyone have an information on this?

 

I found this for Materials here:

http://forums.autodesk.com/t5/inventor-customization/updatefromglobal-for-materials/m-p/5086980/high...

 

Using iLogic this works:

oDoc = ThisDoc.Document
oDoc.ComponentDefinition.Material.UpdateFromGlobal

 

This does not:

oDoc = ThisDoc.Document
oDoc.ComponentDefinition.Color.UpdateFromGlobal

 

Nor does this:

oDoc = ThisDoc.Document
oDoc.ComponentDefinition.Appearance.UpdateFromGlobal

 

 

Thanks in advance,

Curtis

EESignature

976 Views
4 Replies
Replies (4)
Message 2 of 5

adam.nagy
Autodesk Support
Autodesk Support

Hi Curtis,

 

This is the feedback I got.

>>>>>

I think the PartDocument.ActiveRenderStyle.UpdateFromGlobal may satisfy the customer, but we recommend to use the Asset to update the appearance instead of the legacy RenderStyle.

 

After we introduced the Asset(Appearance and Material) to replace the legacy RenderStyle/Material style, both in UI and API we have not provided a method to directly update the document appearance/material from library, this is because the document(local) Asset is not mapped to library(global) Asset.

 

For the legacy RenderStyle/Material styles, the styles can be 1-1 mapped between the local/document and global/library, and you can use RenderStyle/Material.UpdateFromGlobal/SaveToGlobal to  update the local/global styles. 

 

For the Asset we have appearance Asset and material Asset. To update the document appearance Asset, users should find the Asset from library that with the same name, then get the color AssetValue from library Asset, and set it to the document appearance Asset. To update the appearance Asset for a material Asset, users should find the MaterialAsset from library that has the same name as the PartDocument.ActiveMaterial, and get library MaterialAsset.AppearanceAsset and copy it to document and then set the copied Asset to the local MaterialAsset.AppearanceAsset.

<<<<<

 

I hope this helps.

 

Cheers,



Adam Nagy
Autodesk Platform Services
0 Likes
Message 3 of 5

Curtis_Waguespack
Consultant
Consultant

Hi adam.nagy,

 

I'll have to find some time later to see if there's a solution in that message, but I appreciate you looking into this.

 

Thanks,

Curtis

EESignature

0 Likes
Message 4 of 5

RasmusBredal
Advocate
Advocate

Hey Curtis 

 

This one works for Appearances

 

Dim pDoc As PartDocument
pDoc = ThisApplication.ActiveDocument

For i = 1 To pDoc.RenderStyles.Count
	If pDoc.RenderStyles.Item(i).UpToDate = False Then
		pDoc.RenderStyles.Item(i).UpdateFromGlobal
	End If
Next

 

 

Message 5 of 5

freesbee
Collaborator
Collaborator

@RasmusBredal wrote:

Hey Curtis 

This one works for Appearances

Dim pDoc As PartDocument
pDoc = ThisApplication.ActiveDocument

For i = 1 To pDoc.RenderStyles.Count
	If pDoc.RenderStyles.Item(i).UpToDate = False Then
		pDoc.RenderStyles.Item(i).UpdateFromGlobal
	End If
Next

...if this one works, it would maybe do the job for the discontinued "RenderStyles".

The solution for MaterialAssets has been documented by @VGonsalves here:

UpdateFromGlobal for Materials

(thank you so much, I've been struggling hours before figuring it out)

Massimo Frison
CAD R&D // PDM Admin · Hekuma GmbH
0 Likes