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: 

HRESULT: 0x80004005 (E_FAIL) during API execution of assembly constrain

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
bartlomiej.czarniakBNLBF
326 Views, 2 Replies

HRESULT: 0x80004005 (E_FAIL) during API execution of assembly constrain

Hi,

 

I'm playing with API vb.net code in Visual Studio and I faced error that stoped me progressing and I don't know how to solve it. Maybe someone has idea.

I'm running code in assembly with 2 parts. I want only constrain it with mate constrain by origin planes of each part. Code below gives me HRESULT: 0x80004005 (E_FAIL).

 

  Dim oAssyDoc As Inventor.AssemblyDocument
        oAssyDoc = invApp.ActiveDocument

        Dim oCompDef As Inventor.AssemblyComponentDefinition
        oCompDef = oAssyDoc.ComponentDefinition

        Dim oPartFlange As Inventor.ComponentOccurrence
        oPartFlange = oCompDef.Occurrences.Item(1)

        Dim oPartPipe As Inventor.ComponentOccurrence
        oPartPipe = oCompDef.Occurrences.Item(2)


        Dim BaseYZ As Inventor.WorkPlane
        BaseYZ = oCompDef.WorkPlanes.Item(1)

        Dim BaseYZPipe As Inventor.WorkPlane
        BaseYZPipe = oPartPipe.Definition.WorkPlanes.Item(1)

        Dim BaseYZFlange As Inventor.WorkPlane
        BaseYZFlange = oPartFlange.Definition.WorkPlanes.Item(1)

        'MsgBox("test " & BaseYZPipe.Name)

        oCompDef.Constraints.AddMateConstraint(BaseYZFlange, BaseYZPipe, 0)

 

 Code works well, I can read names of occurances in assembly, but it failes on constraining. I will appriciate any help.

Labels (1)
  • API
2 REPLIES 2
Message 2 of 3

@bartlomiej.czarniakBNLBF 

 

Please note that whenever you are using something from Occurrences (i.e. Work plane, Face, Work Axis, etc.) you need to create a proxy, If you are using something from the active assembly, the proxy is not needed. See below code.

 

  	Dim oAssyDoc As Inventor.AssemblyDocument
        oAssyDoc = invApp.ActiveDocument

        Dim oCompDef As Inventor.AssemblyComponentDefinition
        oCompDef = oAssyDoc.ComponentDefinition

        Dim oPartFlange As Inventor.ComponentOccurrence
        oPartFlange = oCompDef.Occurrences.Item(1)

        Dim oPartPipe As Inventor.ComponentOccurrence
        oPartPipe = oCompDef.Occurrences.Item(2)


                Dim BaseYZ As Inventor.WorkPlane
                BaseYZ = oCompDef.WorkPlanes.Item(1)

                Dim BaseYZPipe As Inventor.WorkPlane
		BaseYZPipe = oPartPipe.Definition.WorkPlanes.Item(1)
        
		Dim BaseYZFlange As Inventor.WorkPlane
                BaseYZFlange = oPartFlange.Definition.WorkPlanes.Item(1)
	
		Dim oWP1 As WorkPlaneProxy
		Dim oWP2 As WorkPlaneProxy
		oPartFlange.CreateGeometryProxy(BaseYZFlange, oWP1)
		oPartPipe.CreateGeometryProxy(BaseYZPipe, oWP2)
				
		'MsgBox("test " & BaseYZPipe.Name)
                 oCompDef.Constraints.AddMateConstraint(oWP1,oWP2,"0")  

 

Hope this will help you.

If this answer has solved your problem please ACCEPT SOLUTION and hit like if you found it helpful..!


Regards,
Dutt Thakar
LinkedIn
Message 3 of 3

Wow! That was it! Thank you very much, I didn't have a clue about those proxy geometries. Is this applicable for axis and planes of solids as well?

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

Post to forums  

Technology Administrators


Autodesk Design & Make Report