Color as parameter

Color as parameter

michalCDNJV
Explorer Explorer
427 Views
2 Replies
Message 1 of 3

Color as parameter

michalCDNJV
Explorer
Explorer

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

428 Views
2 Replies
Replies (2)
Message 2 of 3

WCrihfield
Mentor
Mentor

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

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 3

Darkforce_the_ilogic_guy
Advisor
Advisor

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

 

 

0 Likes