error handling. If level of detail does not exist

error handling. If level of detail does not exist

william
Advocate Advocate
470 Views
2 Replies
Message 1 of 3

error handling. If level of detail does not exist

william
Advocate
Advocate

Hello 

I want to be able to say, change the level of detail to "Export" 

If the level of detail "Export" does not exist, then show this message box, else continue. 

 

'Set the level Of detail To Export 
LOD_NAME = "Export"
'On Error Resume Next

ThisApplication.ActiveDocument.ComponentDefinition.RepresentationsManager.LevelofDetailRepresentations(LOD_NAME).Activate
If ThisApplication.ActiveDocument.ComponentDefinition.RepresentationsManager.LevelofDetailRepresentations(LOD_NAME) = False 
	MessageBox.Show("Level of Detail does not exist", "Error Handling")
End If 

'Set the level Of detail back To Default 
'ThisApplication.ActiveDocument.ComponentDefinition.RepresentationsManager.LevelofDetailRepresentations("Master").Activate

I have come up with the above but it is not working at the moment.

I am using another piece of code as precedent, which i have pasted below. 

	'Dim strFileName = ThisDoc.FileName(False)
	'Save the current document	
	'ThisDoc.Save
	'Take the current document's name and create the corresponding idw filename, assuming the same
	strIDWFilename = ThisDoc.ChangeExtension(".idw")
	MessageBox.Show(strIDWFilename, "Title")
	On Error Resume Next

	'Close the current document
	'ThisApplication.CommandManager.ControlDefinitions.Item("AppFileCloseCmd").Execute
	'open the indexed file, false opens the file without generating the graphics
	ThisApplication.Documents.Open(strIDWFilename, True)
	If System.IO.File.Exists(strIDWFilename) = False
		MessageBox.Show("Error executing rule. Please ensure that the drawing exists, and has been downloaded from Vault. The drawing must have the same name as this file.", "Error Handling")
	End If 

 

Appreciate any help

Regards

 

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

Curtis_Waguespack
Consultant
Consultant
Accepted solution

Hi @william ,

 

This ilogic example should work.

 

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

 

'Set the level Of detail To Export 
LOD_NAME = "Export"

Dim oRepMan As RepresentationsManager
oRepMan = ThisApplication.ActiveDocument.ComponentDefinition.RepresentationsManager

Try
	oRepMan.LevelOfDetailRepresentations(LOD_NAME).Activate
Catch
	MessageBox.Show("The Level of Detail named '" & _
	LOD_NAME & "' does not exist", "Error Handling")
	'Set the level Of detail back To Default 
	oRepMan.LevelOfDetailRepresentations("Master").Activate
End Try 

 

 

 

EESignature

0 Likes
Message 3 of 3

william
Advocate
Advocate

Thankyou. That works great

0 Likes