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: 

SetDesignViewRepresentation error in Weldment

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
Mike_Dzwigalski
225 Views, 2 Replies

SetDesignViewRepresentation error in Weldment

Mike_Dzwigalski
Explorer
Explorer

I made an iLogic rule which iterates through each of the components within an assembly and switches the design view to "Default" but when I attempt to run the rule in a weldment it errors out with "The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))". I have tested the code in a normal assembly and it performs as I had expected.

 

I still have to add coding to add "Default" in event it doesn't exist but I want to first solve this error.

 

When I look at the logger for the information I requested I notice it is looking at the weldment itself as an occurrence, then attempts to set the design view then errors out. Is this being done because it is a weldment?

 

The code I am using is below and I have added a test weldment. 

 

Thanks

 

Dim oAssyDoc As AssemblyDocument
oAssyDoc = ThisApplication.ActiveDocument

Dim oAssyCompDef As ComponentDefinition
oAssyCompDef = oAssyDoc.ComponentDefinition

Dim oOccurrences As ComponentOccurrences
oOccurrences = oAssyCompDef.Occurrences

Dim oOcc As ComponentOccurrence

For Each oOcc In oOccurrences
	
	Logger.Info(oOcc.DefinitionDocumentType)
	If oOcc.DefinitionDocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
		Logger.Info(oOcc.BOMStructure)
		Logger.Info(oOcc.Name)
		oOcc.SetDesignViewRepresentation("Default", , True)
		Logger.Info("Confirm If")
	End If
Next

 

0 Likes

SetDesignViewRepresentation error in Weldment

I made an iLogic rule which iterates through each of the components within an assembly and switches the design view to "Default" but when I attempt to run the rule in a weldment it errors out with "The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))". I have tested the code in a normal assembly and it performs as I had expected.

 

I still have to add coding to add "Default" in event it doesn't exist but I want to first solve this error.

 

When I look at the logger for the information I requested I notice it is looking at the weldment itself as an occurrence, then attempts to set the design view then errors out. Is this being done because it is a weldment?

 

The code I am using is below and I have added a test weldment. 

 

Thanks

 

Dim oAssyDoc As AssemblyDocument
oAssyDoc = ThisApplication.ActiveDocument

Dim oAssyCompDef As ComponentDefinition
oAssyCompDef = oAssyDoc.ComponentDefinition

Dim oOccurrences As ComponentOccurrences
oOccurrences = oAssyCompDef.Occurrences

Dim oOcc As ComponentOccurrence

For Each oOcc In oOccurrences
	
	Logger.Info(oOcc.DefinitionDocumentType)
	If oOcc.DefinitionDocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
		Logger.Info(oOcc.BOMStructure)
		Logger.Info(oOcc.Name)
		oOcc.SetDesignViewRepresentation("Default", , True)
		Logger.Info("Confirm If")
	End If
Next

 

Tags (2)
2 REPLIES 2
Message 2 of 3

JelteDeJong
Mentor
Mentor
Accepted solution

Your assumption that welds are seen as occurrences is correct. You can skip the welds like this:

Dim oAssyDoc As AssemblyDocument = ThisDoc.Document
Dim oAssyCompDef As ComponentDefinition = oAssyDoc.ComponentDefinition
Dim oOccurrences As ComponentOccurrences = oAssyCompDef.Occurrences

For Each oOcc As ComponentOccurrence In oOccurrences

	If (oOcc.Definition.Type = ObjectTypeEnum.kWeldsComponentDefinitionObject) Then
		Dim weldOccDefinition As WeldsComponentDefinition = oOcc.Definition
		' This is impossible ;-)
		' weldOccDefinition.SetDesignViewRepresentation("Default", , True)

		MsgBox("Found a weld lets continue to the next oOcc")
		Continue For
	End If


	logger.Info(oOcc.DefinitionDocumentType)
	If oOcc.DefinitionDocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
		logger.Info(oOcc.BOMStructure)
		logger.Info(oOcc.Name)
		oOcc.SetDesignViewRepresentation("Default", , True)
		logger.Info("Confirm If")
	End If
Next

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

Your assumption that welds are seen as occurrences is correct. You can skip the welds like this:

Dim oAssyDoc As AssemblyDocument = ThisDoc.Document
Dim oAssyCompDef As ComponentDefinition = oAssyDoc.ComponentDefinition
Dim oOccurrences As ComponentOccurrences = oAssyCompDef.Occurrences

For Each oOcc As ComponentOccurrence In oOccurrences

	If (oOcc.Definition.Type = ObjectTypeEnum.kWeldsComponentDefinitionObject) Then
		Dim weldOccDefinition As WeldsComponentDefinition = oOcc.Definition
		' This is impossible ;-)
		' weldOccDefinition.SetDesignViewRepresentation("Default", , True)

		MsgBox("Found a weld lets continue to the next oOcc")
		Continue For
	End If


	logger.Info(oOcc.DefinitionDocumentType)
	If oOcc.DefinitionDocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
		logger.Info(oOcc.BOMStructure)
		logger.Info(oOcc.Name)
		oOcc.SetDesignViewRepresentation("Default", , True)
		logger.Info("Confirm If")
	End If
Next

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

Message 3 of 3

Mike_Dzwigalski
Explorer
Explorer

Thanks for the help!

0 Likes

Thanks for the help!

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

Post to forums  

Autodesk Design & Make Report