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: 

Work Point Proxy Type Mismatch

8 REPLIES 8
SOLVED
Reply
Message 1 of 9
kakers
1197 Views, 8 Replies

Work Point Proxy Type Mismatch

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

8 REPLIES 8
Message 2 of 9
adam.nagy
in reply to: kakers

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
Message 3 of 9
jdkriek
in reply to: adam.nagy

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.


Message 4 of 9
kakers
in reply to: jdkriek

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

 

 

Message 5 of 9
jdkriek
in reply to: kakers

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
in reply to: jdkriek

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
kakers
in reply to: jdkriek

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
in reply to: kakers

^ 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
kakers
in reply to: jdkriek

Thanks for all the help and effort. This was a bizarre problem.

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

Post to forums  

Autodesk Design & Make Report