Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

inventor custom color on the drawing

9 REPLIES 9
SOLVED
Reply
Message 1 of 10
Lukasz.Dudkowski
1119 Views, 9 Replies

inventor custom color on the drawing

Hello,

 

I want's to create pre-defined list of customized colors  for drawing edges(lines).

 

Issue with I have is that when I create customized color after restart of Inventor the list is blanc.

 

Questions:

1. Is there any possibilities to save created customized colors ?

2. If yes with file is responsible to keep this settings ?

 

BR,

Łukasz Dudkowski

9 REPLIES 9
Message 2 of 10

I think that is just how it is unfortunately.

  Expert Elite
  Inventor Certified Professional
Message 3 of 10

@Lukasz.Dudkowski 

 

 I think you can edit the style library and save your desired colors for lines. After theat you may export the settings file and use for different drawings. Moreover, it may stay intact when you make this drawings as a templet file.

 

bhavik4244_1-1624511825426.pngbhavik4244_2-1624511851091.png

 


Bhavik Suthar
Message 4 of 10
SharkDesign
in reply to: bhavik4244

Bhavik method won't save the custom colours in the pallet you show, but it will save the colours associated with the layers allowing you assign objects to them.

  Expert Elite
  Inventor Certified Professional
Message 5 of 10

@bhavik4244 

Thanks for yours advise, but I will want's to have solution where I perform modification only of the line color. I avare that with your solution I will need multiple layers with multiple colors with will case a little bit of mess.

Message 6 of 10

Can we solve this issue by iLogic ?

I can imagine that we mark multiple views\lines on the drawing and then we run iLogic macro with has drop down menu from with we can select the color and then approve to modified. Will be nice to not change or create layers but only use Customized colors.

Is there someone who can hep to create this type of macro ?

Message 7 of 10

Hi @Lukasz.Dudkowski 

 

Here is an iLogic example that might work for you.

 

You can modify the list to use any colors you want, I just added the ones listed for testing... just give the color a name and RGB values. 

 

I'd make this an external rule, so you can have a single rule to use in all drawings.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

'add any color you want here,
'using the format oList.Add("Color Name | R,G,B")

'see this link for some named colors:
'https://www.color-name.com/color/trending

Dim oList As New ArrayList
oList.Add("Red | 255,0,0")
oList.Add("Green | 0,255,0")
oList.Add("Yellow | 255,255,0")
oList.Add("Cyan | 0,255,255")
oList.Add("Magenta | 255,0,255")
oList.Add("White | 255,255,255")
oList.Add("Black | 0,0,0")
oList.Add("Gray | 155,155,155")
oList.Add("Periwinkle | 204,204,255")
oList.Add("Orange | 255,121,0")
oList.Add("Brown | 177,144,127")

oColor = InputListBox("Select one", oList, "", "ilogic", "List")

'split the name and RGB using the |
sSPlit = Split(oColor, "|")
sColorName = Trim(sSPlit(0))
sColorValues = Trim(sSPlit(1))

'split the Red, Green, Blue values using the comma
sSPlit = Split(sColorValues, ",")
sR = sSPlit(0)
sG = sSPlit(1)
sB = sSPlit(2)

'create the color
oColor = ThisApplication.TransientObjects.CreateColor(sR, sG, sB)

While True


	'select the line segments	
	Dim oSegment As DrawingCurveSegment
	oSegment = ThisApplication.CommandManager.Pick _
		(SelectionFilterEnum.kDrawingCurveSegmentFilter, _
		"Select edges to make " & sColorName & " (press ESC to exit selection)")
	
	If IsNothing(oSegment) Then Exit While
		
	'set the segment color
	oSegment.Parent.Color = oColor


End While

 

Message 8 of 10

@Curtis_Waguespack  This works very close to this what I need.

 

In cases of assembly instead of line selection better is to select the component in model tree. Is this possible to add to code selection from the model tree ?

 

BR,

Łukasz Dudkowski

 

 

Message 9 of 10

Hi @Lukasz.Dudkowski 

 

Give this a try... I didn't test it much, but it seems to work as expected.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

Sub Main
	'adapted from iLogic Code by Jhoel Forshav - originally posted at 
	'https://clintbrown.co.uk/ilogic-occurrence-selection-filter-In-drawings/

	'[ create color / color list
	Dim oList As New ArrayList
	oList.Add("Red | 255,0,0")
	oList.Add("Green | 0,255,0")
	oList.Add("Yellow | 255,255,0")
	oList.Add("Cyan | 0,255,255")
	oList.Add("Magenta | 255,0,255")

	sColor = InputListBox("Select one", oList, "", "ilogic", "List")

	'split the name and RGB using the |
	sSPlit = Split(sColor, "|")
	sColorName = Trim(sSPlit(0))
	sColorValues = Trim(sSPlit(1))

	'split the Red, Green, Blue values using the comma
	sSPlit = Split(sColorValues, ",")
	sR = sSPlit(0)
	sG = sSPlit(1)
	sB = sSPlit(2)

	'create the color
	Dim oColor As Color
	oColor = ThisApplication.TransientObjects.CreateColor(sR, sG, sB)
	']
	
	While True
		Dim oSelect As New SelectClass
		Dim oCurve As DrawingCurve = oSelect.SelectCurve(ThisApplication)
		If IsNothing(oCurve) Then Exit While

		Dim oOcc As ComponentOccurrence
		oOcc = oCurve.ModelGeometry.Parent.Parent

		Dim oView As DrawingView
		oView = oCurve.Parent

		oSelect = Nothing

		'Get all Of the curves associated with this occurrence. 
		Dim drawcurves As DrawingCurvesEnumerator
		drawcurves = oView.DrawingCurves(oOcc)
		If Err.Number = 0 Then
			On Error GoTo 0

			Dim drawCurve As DrawingCurve
			For Each drawCurve In drawcurves
				Dim segment As DrawingCurveSegment
				For Each segment In drawCurve.Segments
					segment.Parent.Color = oColor
				Next
			Next  								'
		End If
	End While
End Sub


Class SelectClass

	Private WithEvents oInteractEvents As InteractionEvents
	Private WithEvents oSelectEvents As SelectEvents
	Private bTooltipEnabled As Boolean
	Private ThisApplication As Inventor.Application
	Private SelectedCurve As DrawingCurve
	Private stillSelecting As Boolean = True


	Public Function SelectCurve(oApp As Inventor.Application)
		ThisApplication = oApp
		oInteractEvents = ThisApplication.CommandManager.CreateInteractionEvents
		oInteractEvents.InteractionDisabled = False
		oSelectEvents = oInteractEvents.SelectEvents
		oSelectEvents.AddSelectionFilter(SelectionFilterEnum.kDrawingCurveSegmentFilter)
		oSelectEvents.WindowSelectEnabled = False
		bTooltipEnabled = ThisApplication.GeneralOptions.ShowCommandPromptTooltips
		ThisApplication.GeneralOptions.ShowCommandPromptTooltips = True
		oInteractEvents.StatusBarText = "Pick part occurrence."
		oInteractEvents.Start()
		AppActivate(ThisApplication.Caption)
		While stillSelecting
			ThisApplication.UserInterfaceManager.DoEvents()
		End While
		Return SelectedCurve
	End Function

	Private Sub oInteractEvents_OnTerminate() Handles oInteractEvents.OnTerminate
		ThisApplication.GeneralOptions.ShowCommandPromptTooltips = bTooltipEnabled
		oSelectEvents = Nothing
		oInteractEvents = Nothing
		stillSelecting = False
	End Sub

	Private Sub oSelectEvents_OnPreselect(ByRef PreSelectEntity As Object, ByRef DoHighlight As Boolean, _
		ByRef MorePreSelectEntities As ObjectCollection, ByVal SelectionDevice As SelectionDeviceEnum, _
		ByVal ModelPosition As Point, ByVal ViewPosition As Inventor.Point2d, _
		ByVal View As Inventor.View) Handles oSelectEvents.OnPreselect

		Try
			Dim oCurves As DrawingCurvesEnumerator = DirectCast(PreSelectEntity, DrawingCurveSegment) _
			.Parent.Parent.DrawingCurves(DirectCast(PreSelectEntity, DrawingCurveSegment) _
			.Parent.ModelGeometry.Parent.Parent)
			Dim oCol As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
			For Each oCurve As DrawingCurve In oCurves
				For Each oSeg As DrawingCurveSegment In oCurve.Segments
					If oSeg IsNot PreSelectEntity Then oCol.Add(oSeg)
				Next
			Next
			MorePreSelectEntities = oCol
			DoHighlight = True
		Catch
			DoHighlight = False
		End Try

	End Sub

	Private Sub oSelectEvents_OnSelect(ByVal JustSelectedEntities As ObjectsEnumerator, _
		ByVal SelectionDevice As SelectionDeviceEnum, ByVal ModelPosition As Point, _
		ByVal ViewPosition As Point2d, ByVal View As Inventor.View) Handles oSelectEvents.OnSelect

		SelectedCurve = DirectCast(JustSelectedEntities.Item(1), DrawingCurveSegment).Parent

		ThisApplication.CommandManager.StopActiveCommand
	End Sub


End Class

 

Message 10 of 10

Thanks it works. 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report