Announcements

Starting in December, we will archive content from the community that is 10 years and older. This FAQ provides more information.

iLogic to get appearance from part (paint color) into drawing custom iProperty

hanshags
Participant
Participant

iLogic to get appearance from part (paint color) into drawing custom iProperty

hanshags
Participant
Participant

Hello All,

I'm still a bit newbie at iLogic - but have managed to learn a lot already from other posts here on the forum - thanks for that 🙂  So, I have a little problem - I would like some help how best to do it.

 

I have with success used the following code to get the material from a part into drawing, and use it to set custom iProperty:

modelName = IO.Path.GetFileName(ThisDrawing.ModelDocument.FullFileName)
iProperties.Value("Custom", "PartMaterial") = UCase(iProperties.Material(modelName))

 

I can then manipulate and use the "PartMaterial" value as I needed in the dwg.

This works as expected - so far so good.

 

Now, I try to do the same for getting the "appearance" - paint color (PartColor) from the model and to be used similarly:

modelName = IO.Path.GetFileName(ThisDrawing.ModelDocument.FullFileName)
iProperties.Value("Custom", "Paint") = UCase(iProperties.PartColor(modelName))

But this I can't get to work. I tried "appearance" instead of "PartColor" etc. - but maybe this is where I go wrong?

I further get the following error:

Error in rule: GetPaint, in document: Square Plate 1

Change for string "Square Plate 1.ip" to typo 'Integer' is not valid.

 

Hope you can help 🙂

 

0 Likes
Reply
Accepted solutions (2)
302 Views
4 Replies
Replies (4)

A.Acheson
Mentor
Mentor
Accepted solution

Looking through the documentation there is no object referencing for the partcolour iproperty. It is designed to be run in the part file. See iLogic API here with list of iproperties. Notice material has an object and part colour does not. 

 

You can retrieve the same information using the inventor API. Reference first the document then the active appearance asset then the name. 

 

Active Appearance Syntax Link

PartDocument.ActiveAppearance() As Asset

 

 

Dim partDoc as PartDocument= ThisDrawing.ModelDocument
Dim partColour as String = partDoc.ActiveAppearance.Name

MessageBox.Show(partColour,"iLogic")

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan

hanshags
Participant
Participant

Many thanks @A.Acheson this worked 😉

I get "1: RAL 9005 Jet Black" as output, is there a way to only list the actual appearance, hence without the "1: " ?

0 Likes

A.Acheson
Mentor
Mentor
Accepted solution

This should be possible. Use the Asset DisplayName instead. Link to property here.

Replace "Name" for "DisplayName" and that should get the name the user sees if different from internal name.

Syntax

Asset.DisplayName() As String

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan

hanshags
Participant
Participant
Worked like a charm 🙂
Many thanks!
0 Likes