Get Drawing Sheet Color

Get Drawing Sheet Color

ccoomes
Advocate Advocate
897 Views
3 Replies
Message 1 of 4

Get Drawing Sheet Color

ccoomes
Advocate
Advocate

I am looking to create an iLogic rule that will change the color of the drawing sheet, dependant on what the color already is.

 

So if the sheet color is white, change it to beige and if it is beige, change it to white.

 

The first part I am stumbling on is how to get the drawing sheet color so it can be checked to see what it is.

 

Is this possible, and if so how can it be done?

 

I have to code to change the sheet color, but not how to get the current color as a string.

 

The second part is does anyone know the color code for the default beige?  The closest I can get is 235, 234, 219 (EBEADB) but would like to know the color code if possible.  Not essential, just trying to get to correct.

0 Likes
Accepted solutions (1)
898 Views
3 Replies
Replies (3)
Message 2 of 4

Michael.Navara
Advisor
Advisor
Accepted solution

Are you looking for this?

Dim drw As DrawingDocument = ThisDoc.Document
Dim sheetColor As Color = drw.SheetSettings.SheetColor
Logger.Info(String.Format("[{0}, {1}, {2}]", sheetColor.Red, sheetColor.Green, sheetColor.Blue))
0 Likes
Message 3 of 4

ccoomes
Advocate
Advocate

Thanks to @Michael.Navara i managed to work it out and this is the code:

 

Public Sub Main()
	'Switches the colour of ALL of the Drawing Sheets, based on the Drawing Sheet Colour
	'If the Colour is white, it will go to Default Beige
	'If the Colour Default Beige, it will go White

	Dim oDwg As DrawingDocument = ThisApplication.ActiveDocument
	'Set the Parameters for the White Sheet Colour
	Dim oWhite As Color = ThisApplication.TransientObjects.CreateColor(255, 255, 255) ' White
	Dim oWhiteRGB As String = String.Format("{0}, {1}, {2}", oWhite.Red, oWhite.Green, oWhite.Blue)

	'Set the Parameters for the Default Beige Sheet Colour
	Dim oBeige As Color = ThisApplication.TransientObjects.CreateColor(235, 234, 219) ' Default Beige
	Dim oBeigeRGB As String = String.Format("{0}, {1}, {2}", oBeige.Red, oBeige.Green, oBeige.Blue)

	'Get the colour of the Drawing Sheets
	Dim oShtColour As Color = oDwg.SheetSettings.SheetColor
	Dim oShtColourRGB As String = String.Format("{0}, {1}, {2}", oShtColour.Red, oShtColour.Green, oShtColour.Blue)

	'Change the colour of ALL Sheets
	If oShtColourRGB = oWhiteRGB Then
		oDwg.SheetSettings.SheetColor = oBeige
	ElseIf oShtColourRGB = oBeigeRGB Then
		oDwg.SheetSettings.SheetColor = oWhite
	Else
		'Do Nothing
		i = MessageBox.Show("Not a Standard Sheet Colour!  Do you want to change it to the Default Beige?", "Standard Sheet Colour!", MessageBoxButtons.YesNo)

		If i = vbYes Then
			oDwg.SheetSettings.SheetColor = oBeige
		Else
		End If

	End If

End Sub

 It switches the sheet colour of ALL sheets between Default Beige and White.  If it is not one of the 2 colours, it will ask to change it to Default beige.

Message 4 of 4

rhenstenburg
Advocate
Advocate

The "parchment" color on the drawing sheets has always irritated me when doing a screen capture but I hadn't gotten around to writing my own iLogic routine yet. This is a perfect, easy remedy. 

 

I implemented this code with one addition; a test to make sure that the currently open item is a drawing.

	If ThisApplication.ActiveDocument.DocumentType.ToString <> "kDrawingDocumentObject" Then
		MessageBox.Show("This can only be performed on a drawing.", "ERROR")
		Exit Sub
	End If

  Thanks for posting.

Inventor Pro / Vault Basic
0 Likes