- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Color as parameter
Hello,
Could anyone help me how can I set a color as parameter in inventor?
I'd like to use it to automatic filling up "color" in drawing table. Maybe do you have any iLogic rule for this?
Best regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi @michalCDNJV. The value of a UserParameter can only be either a number, a String (text), or Boolean (True/False), so you can't actually set its value as a Color directly. You can have the UserParameter's value be the text representing the name of a color. When you create a color object in code, you usually specify 3 to 4 aspects of the color (amount of Red, the amount of Green, and the amount of Blue, each as a number between 0 and 255), then optionally the amount of opacity (as a Double), which ranges from zero (0) to 1 (0 = completely translucent & 1 = completely opaque). And it won't let you store 3 or 4 numbers all as one current value, unless you put it all as one long string (text). Can you please explain more about what you are trying to achieve, so maybe we can help you come up with some alternative ideas?
Wesley Crihfield
(Not an Autodesk Employee)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Yes you can do this with Ilogic. What you need to make sure is that spell corrently ( that make it easy anyway). I do not have at code you need 100 % but here is some code that might give you some idear(for assembly first code) and Part second code.
You can also make it color all view. but I have try to copy and paste as lillte code I could in a short time ... hope it help
//assembly
Dim oAsmDoc As AssemblyDocument
oAsmDoc = ThisDoc.Document
Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = oAsmDoc.ComponentDefinition
Dim oOccurrence As ComponentOccurrence
For Each oOccurrence In oAsmCompDef.Occurrences
Component.Color(oOccurrence.name)="RAL 5003 Sapphire blue"
iLogicVb.UpdateWhenDone = True
Next
End if
End Sub
Sub Colour1
Dim oPartDoc As PartDocument
Try
oPartDoc = ThisApplication.ActiveDocument
Catch
oPartDoc = ThisDoc.Document
End Try
'define the appearance library
Dim oLib As AssetLibrary
oLib = ThisApplication.AssetLibraries("KallesoeMaterialLibrary")
'make sure colors are in assembly doc
Dim libAsset As Asset
libAsset = oLib.AppearanceAssets.Item("RAL 9010 Pure white")
Dim localAsset As Asset
Try
localAsset = oPartDoc.Assets.Item("RAL 9010 Pure white")
Catch
localAsset = libAsset.CopyTo(oPartDoc)
End Try
oPartDoc.ActiveAppearance = localAsset
End Sub