iLogic Change Tube Run Color

iLogic Change Tube Run Color

Anonymous
Not applicable
1,450 Views
6 Replies
Message 1 of 7

iLogic Change Tube Run Color

Anonymous
Not applicable

I'm having trouble changing the color of my tube runs using iLogic. I have an assembly, I've created a tube run within this assembly, and when I try to run the code below at the assembly level the code doesn't work. However, if I open the "Tube and Pipe Runs" file and put the same code in there it works. The problem is that the "Tube and Pipe Runs" file does not pass the overrides back up the the parent assembly file. 

Component.Color("Run01") = "red"
Component.Color("Run02") = "green"

tube and pipe level.gifupper assembly containing tube run.gif

0 Likes
Accepted solutions (1)
1,451 Views
6 Replies
Replies (6)
Message 2 of 7

blair
Mentor
Mentor

You will probably need to change you approach on this. T & P works with "Styles" to change the color of runs and keep them. You would need to have created the "Styles" for each color within your T & P Template File and then have your iLogic select the correct Style. 


Inventor 2020, In-Cad, Simulation Mechanical

Just insert the picture rather than attaching it as a file
Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.
Delta Tau Chi ΔΤΧ

Message 3 of 7

Anonymous
Not applicable

We have a lot of styles(about 25) and we have at least 8 different colors for each style. I was looking for something a little quicker than creating a style for each color. If this is the only option then so be it but I would like to program something. Maybe I can create a routine that creates the styles for me?

0 Likes
Message 4 of 7

Cris_Davis
Enthusiast
Enthusiast

What if I have to place an elbow from Content Center?  I believe your approach will only work for auto routes.

 

Any other suggestions?

0 Likes
Message 5 of 7

blair
Mentor
Mentor

Once you create them in your T & P Template, they are there as long as you save, migrate and paste the Template T & P into the new Inventor template file.


Inventor 2020, In-Cad, Simulation Mechanical

Just insert the picture rather than attaching it as a file
Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.
Delta Tau Chi ΔΤΧ

0 Likes
Message 6 of 7

Anonymous
Not applicable

Cris, maybe you post how we solved this problem? or the approach we took.

0 Likes
Message 7 of 7

Curtis_Waguespack
Consultant
Consultant
Accepted solution

@ phillip.shields

 

I know you were asking for another solution that SiloMan explained offline, but I'll add this iLogic just in case it helps others in the future.

 

( Note we just finished this up on Friday, so it might not be fully rolled out internally yet.)

 

 

' Get the active document.  
Dim oDoc As AssemblyDocument
oDoc = ThisApplication.ActiveDocument

' Get the UserParameters collection
Dim userParams As UserParameters
userParams = oDoc.ComponentDefinition.Parameters.UserParameters

'[ check For Parameter And create If Not found
Try
	oTest = Parameter("Color_List") 
Catch
	oParam = userParams.AddByValue("Color_List","Black", UnitsTypeEnum.kTextUnits)
End Try

'create color list
Dim ColorArrayList As New ArrayList
ColorArrayList.Clear
ColorArrayList.add("Black")
ColorArrayList.add("White")
ColorArrayList.add("Red")
ColorArrayList.add("Yellow")
ColorArrayList.add("Cyan")
ColorArrayList.add("Magenta")


MultiValue.List("Color_List") = ColorArrayList
']

'[ create list of runs
Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition
Dim MyArrayList As New ArrayList

'Iterate through all of the occurrences
Dim oOccurrence As ComponentOccurrence
For Each oOccurrence In oAsmCompDef.Occurrences.AllReferencedOccurrences(oAsmCompDef)  
	 oDef = oOccurrence.Definition.Document
	Dim bIsRunDocument As Boolean
	bIsRunDocument = oDef.DocumentInterests.HasInterest("Piping Run Environment")
	

	If bIsRunDocument = True Then
		MyArrayList.add( oOccurrence.Name )
	End If
Next


'check For Parameter And create If Not found
Try
	oTest = Parameter("Runs_List") 
Catch
	oParam = userParams.AddByValue("Runs_List","", UnitsTypeEnum.kTextUnits)
End Try

'] MultiValue.List("Runs_List") = MyArrayList


oColor = Color_List
oRun = Runs_List

'[ try to get the named asset / color
Dim localAsset As Asset

Try 
	localAsset = oDoc.Assets.Item(oColor)
Catch

	
	Dim assetLib As AssetLibrary
	assetLib = ThisApplication.AssetLibraries.Item("APPEAR")
	
	Dim libAsset As Asset
	libAsset = assetLib.AppearanceAssets.Item(oColor)
	
	' Copy the asset locally.
	localAsset = libAsset.CopyTo(ThisApplication.ActiveDocument)
End Try
'] 

'set the color of the run 
For Each oOccurrence In oAsmCompDef.Occurrences.AllReferencedOccurrences(oAsmCompDef)  	
	If oOccurrence.Name = oRun Then			
		oOccurrence.Appearance = localAsset					
	End If
Next


 

 

 

EESignature

0 Likes