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: 

Is their anything wrong with code?

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
mslosar
873 Views, 2 Replies

Is their anything wrong with code?

It's based of another post and modified. Essentially i'm having to set the visibility, etc of all the pieces of a circular pattern.

 

The rule works completely fine in the assembly it's written in. This assembly inserted into another assembly. When saving all files in the upper level assembly, it generates and error on this rule in the sub assembly.

 

The code:

 

Dim oDoc As AssemblyDocument 
oDoc = ThisApplication.ActiveDocument 
Dim oPattern As OccurrencePattern 
oPattern = oDoc.ComponentDefinition.OccurrencePatterns.Item("FRS_Pattern 3:1") 
Dim oPatternElement As OccurrencePatternElement 
For Each oPatternElement In oPattern.OccurrencePatternElements 
	Dim oOcc As ComponentOccurrence 
		For Each oOcc In oPatternElement.Occurrences 
			If FRS_SEGMENTS= 1 then
				oOcc.Enabled = False
				oOcc.Visible = False
				oOcc.BOMStructure = 51972
				else
				oOcc.Enabled = True
				oOcc.Visible = True
				oOcc.BOMStructure = 51969
			End if
		Next 
	Next  

 

The error:

 

iLogic Rule Error in rule: FRS_YN, in document: U_TIP_BODY_ASSY.iam

Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))

 

System.Runtime.InteropServices.COMException (0x80004005): Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))

at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)

at Inventor.OccurrencePatterns.get_Item(Object Index)

at LmiRuleScript.Main()

at Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)

at e.a(String A_0)

 

 

2 REPLIES 2
Message 2 of 3
wowens63
in reply to: mslosar

just thinking out loud..if you set  oDoc = ThisApplication.ActiveDocument your setting the oDoc = to the upper and not = to the assembly the code is writen in?

Message 3 of 3
mslosar
in reply to: wowens63

I think that's right.

 

I changed it to ThisDoc.Document and it's passed the few tests i've thrown at it thus far.

 

Fingers crossed that it lasts. 🙂

 

After posting i went back and stared at it and was thinking the same thing.

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

Post to forums  

Autodesk Design & Make Report