Work Point Proxy Type Mismatch

Work Point Proxy Type Mismatch

Anonymous
Not applicable
2,060 Views
8 Replies
Message 1 of 9

Work Point Proxy Type Mismatch

Anonymous
Not applicable

Hello. I'm working on mating two assemblies together by work points on a part inside of them. 

 

Here is the code I'm using. It worked with work planes, but when repurposed it to work points, I get a type mismatch when the code tries to generate the work point proxies:

 

    Dim oPartPoint1 As WorkPoint
    oPartPoint1 = oOcc1.Definition.WorkPoints.Item("botMatePoint")

    Dim oPartPoint2 As WorkPoint
    oPartPoint2 = oOcc2.Definition.WorkPoints.Item("matePoint")

    Dim oAsmPoint1 As WorkPointProxy
    oOcc1.CreateGeometryProxy(oPartPoint1, oAsmPoint1)

    Dim oAsmPoint2 As WorkPointProxy
    oOcc2.CreateGeometryProxy(oPartPoint2, oAsmPoint2)

Any thoughts?


Thanks

0 Likes
Accepted solutions (1)
2,061 Views
8 Replies
Replies (8)
Message 2 of 9

adam.nagy
Autodesk Support
Autodesk Support

Hi,

 

That is strange. I have the following assembly and part:

 workpointproxy.png

... and this VBA code works fine with it:

Sub GetWorkPointProxy()
    Dim asm As AssemblyDocument
    Set asm = ThisApplication.ActiveDocument
    
    Dim occ As ComponentOccurrence
    Set occ = asm.ComponentDefinition.Occurrences(1)
    
    Dim wp As WorkPoint
    Set wp = occ.Definition.WorkPoints("MyWorkPoint")
    
    Dim wpp As WorkPointProxy
    Call occ.CreateGeometryProxy(wp, wpp)
    
    MsgBox (wpp.Name)
End Sub

Cheers,



Adam Nagy
Autodesk Platform Services
0 Likes
Message 3 of 9

jdkriek
Advisor
Advisor

Works fine in iLogic as well...

 

Dim asm As AssemblyDocument = ThisApplication.ActiveDocument
Dim occ As ComponentOccurrence = asm.ComponentDefinition.Occurrences(1)
Dim wp As WorkPoint = occ.Definition.WorkPoints("MyWorkPoint")
Dim wpp As WorkPointProxy
occ.CreateGeometryProxy(wp, wpp)
MsgBox (wpp.Name)

 

kakers can you post the rest of your code? Something else is going on.

Jonathan D. Kriek
MFG Solutions Engineer
KETIV Technologies, Inc.


0 Likes
Message 4 of 9

Anonymous
Not applicable

Try this assembly on for size. This is my whole run of code with a stripped down assembly due to NDA issues.

 

 

0 Likes
Message 5 of 9

jdkriek
Advisor
Advisor

Interesting, am I wrong in seeing that it's applying the constraint even with the Type mismatch?

Jonathan D. Kriek
MFG Solutions Engineer
KETIV Technologies, Inc.


Message 6 of 9

jdkriek
Advisor
Advisor
Accepted solution

Defining oOcc1 and oOcc2 As ComponentOccurrence let it work without errors.

 

Dim oOcc1 As ComponentOccurrence
oOcc1 = oCurrAssy.Occurrences.Item(1)
' ...............
Dim oOcc2 As ComponentOccurrence
oOcc2 = oCurrAssy.Occurrences.Item(1)
Jonathan D. Kriek
MFG Solutions Engineer
KETIV Technologies, Inc.


Message 7 of 9

Anonymous
Not applicable

Thanks so much. Here's some additional insight from Mike Deck:

 

I did get the type mismatch error, and I found a solution. All the changes are in this block of code:

 

   

    If DEBUGMSGS Then MsgBox("Grabbing Current Comp")

    oCurrAssy = Component.InventorComponentInThisContext("MIDASSY" & x)

    If DEBUGMSGS Then MsgBox("Grabbing Current Comp Stringer")

    Dim oOcc1 As ComponentOccurrenceProxy = oCurrAssy.SubOccurrences.Item(1)

   

    If DEBUGMSGS Then MsgBox("Grabbing Previous Comp")

    oPrevAssy = Component.InventorComponentInThisContext("MIDASSY" & x-1)

    If DEBUGMSGS Then MsgBox("Grabbing Previous Comp Stringer")

    Dim oOcc2 As ComponentOccurrenceProxy = oPrevAssy.SubOccurrences.Item(1)

    ' Work point from each occurrence.  This goes to the

    ' component definition of the part to get this information.

 

The main change is to explicitly declare oOcc1 and oOcc2 as ComponentOccurrenceProxy.

I’m not sure exactly why that is required. I think it is because the CreateGeometryProxy method can be used on both a ComponentOccurrence and a ComponentOccurrenceProxy object. It might also work if you declared it as ComponentOccurrence.

 

The other change is to avoid going to the definition of the subassembly. Instead, use its SubOccurrences property to get to the part. This keeps everything in the context of the assembly that is running the rule.

Message 8 of 9

jdkriek
Advisor
Advisor

^ Indeed, ComponentOccurrenceProxy is better - I got some warnings using ComponentOccurrence, but it worked 😉

Jonathan D. Kriek
MFG Solutions Engineer
KETIV Technologies, Inc.


Message 9 of 9

Anonymous
Not applicable
Thanks for all the help and effort. This was a bizarre problem.
0 Likes