WorkPlaneProxy error

WorkPlaneProxy error

Anonymous
Not applicable
437 Views
1 Reply
Message 1 of 2

WorkPlaneProxy error

Anonymous
Not applicable

I have the following code that is giving me fits. I am trying to constrain a part. It Fails at oPart.CreateGeometryProxy() the error is

"Type mismatch. (Exception from HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH))" For some reason it does not like oProxyPlane.

Thanks in advance

Kevin

 

 

SyntaxEditor Code Snippet

Dim oAsmDoc as AssemblyDocument = ThisApplication.ActiveDocument
Dim oAsmCompDef As AssemblyComponentDefinition = oAsmDoc.ComponentDefinition
Dim oTG As TransientGeometry = ThisApplication.TransientGeometry
Dim oMatrix As Matrix = ThisApplication.TransientGeometry.CreateMatrix

'set references for Assembly planes
Dim oMasterPlaneYZ As WorkPlane = oAsmCompDef.Workplanes(1)
'Dim oMasterPlaneXZ As WorkPlane = oAsmCompDef.Workplanes(2)'Dim oMasterPlaneXY As WorkPlane = oAsmCompDef.Workplanes(3)

Dim oPart = ComponentOccurence
oPart = oAsmCompDef.Occurrences.Item(1)
oPart.Grounded = False

' define part planes
Dim oPartPlane As WorkPlane = oPart.Definition.WorkPlanes(1)

' define proxies
Dim oProxyPlane As WorkPlaneProxy = Nothing
Call oPart.CreateGeometryProxy(oPartPlane, oProxyPlane)

Call oAsmCompDef.Constraints.AddMateConstraint(oMasterPlaneYZ, oProxyPlane, 0)


 

0 Likes
Accepted solutions (1)
438 Views
1 Reply
Reply (1)
Message 2 of 2

JaneFan
Autodesk
Autodesk
Accepted solution

Hey @Anonymous, 

 

You code looks good, but one line need be changed. Please have a try with one-line-updated code as below: 

Code Snippet

Dim oAsmDoc As AssemblyDocument = ThisApplication.ActiveDocument
Dim oAsmCompDef As AssemblyComponentDefinition = oAsmDoc.ComponentDefinition
Dim oTG As TransientGeometry = ThisApplication.TransientGeometry
Dim oMatrix As Matrix = ThisApplication.TransientGeometry.CreateMatrix

'set references for Assembly planes
Dim oMasterPlaneYZ As WorkPlane = oAsmCompDef.WorkPlanes(1)
'Dim oMasterPlaneXZ As WorkPlane = oAsmCompDef.Workplanes(2)'Dim oMasterPlaneXY As WorkPlane = oAsmCompDef.Workplanes(3)

Dim oPart  As ComponentOccurrence
oPart = oAsmCompDef.Occurrences.Item(1)
oPart.Grounded = False

' define part planes
Dim oPartPlane As WorkPlane = oPart.Definition.WorkPlanes(1)

' define proxies
Dim oProxyPlane As WorkPlaneProxy 
Call oPart.CreateGeometryProxy(oPartPlane, oProxyPlane)

Call oAsmCompDef.Constraints.AddMateConstraint(oMasterPlaneYZ, oProxyPlane, 0)

 




Jane Fan
Inventor/Fusion QA Engineer