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: 

Proxy / Subassembly / Sheet metal problem

1 REPLY 1
SOLVED
Reply
Message 1 of 2
tom_wise
414 Views, 1 Reply

Proxy / Subassembly / Sheet metal problem

I'm completly lost with this proxy issue.  I don't do much programming in this field.  So far I have the attached assembly as an example (the code is building it all successfully so far).  I want to connect the bottom of the plate on the bushing to the plate of the cover, then have it ask for the centerline of the hole it is to attach to.   Then I need to resize the hole according to the iproperty in the plate.  Can someone help me get this code fixed to attach the plate to the cover and then start a clsSelect event to choose the centerlines via mouse event?  The code below gets the sub assembly component of the plate, and works all the way through the create geometry proxy, but after this, I can't get any examples I've found here to work.  I think it's the sheet metal object in the main assembly.  I do have a clsSelect / Pick standard function included in my Class Modules already.

 

Thanks in advance to anyone that can help.  I'm stuck.

--------------------------------------

Public Sub MateConstraint()

' Get the top assembly document.
    Dim oMainAsmDoc As AssemblyDocument
    Set oMainAsmDoc = ThisApplication.ActiveDocument

' Get a reference to a subassembly in the top assembly.  This case: the Plate below the bushing.
    Dim oSourceSubAsmOcc As ComponentOccurrence
    Set oSourceSubAsmOcc = oMainAsmDoc.ComponentDefinition.Occurrences.ItemByName("HVBushingAssy:1").Definition.Occurrences.ItemByName("BushingPlateHV:1")

' Get a reference to another instance of the top assembly.
    Dim oTargetSubAsmOcc As ComponentOccurrence
    Set oTargetSubAsmOcc = oMainAsmDoc.ComponentDefinition.Occurrences.ItemByName("TopCover3_8:1")

    'Get the extrude feature of the bushing
    Dim oExtrudeFeature As ExtrudeFeature
    Set oExtrudeFeature = oSourceSubAsmOcc.Definition.Features.ExtrudeFeatures(1)

    Dim oSubAssExtProx As ExtrudeFeatureProxy
    Call oSourceSubAsmOcc.CreateGeometryProxy(oExtrudeFeature, oSubAssExtProx)


End Sub

1 REPLY 1
Message 2 of 2
tom_wise
in reply to: tom_wise

Ok I've got it to this point now:

 

Public Sub MateConstraint()

' Get the top assembly document.
    Dim oMainAsmDoc As AssemblyDocument
    Set oMainAsmDoc = ThisApplication.ActiveDocument
    
    Dim oAsmCompDef As AssemblyComponentDefinition
    Set oAsmCompDef = oMainAsmDoc.ComponentDefinition

' Get a reference to a subassembly in the top assembly.  This case: the Plate below the bushing.
    Dim oSourceSubAsmOcc As ComponentOccurrence
    Set oSourceSubAsmOcc = oMainAsmDoc.ComponentDefinition.Occurrences.ItemByName("HVBushingAssy:1").Definition.Occurrences.ItemByName("BushingPlateHV:1")
    Debug.Print oSourceSubAsmOcc.Name
    
' Get a reference to another instance of the top assembly.
    Dim oTargetSubAsmOcc As ComponentOccurrence
    Set oTargetSubAsmOcc = oMainAsmDoc.ComponentDefinition.Occurrences.ItemByName("TopCover3_8:1")
    Debug.Print oTargetSubAsmOcc.Name

'Workplane for Extrude Feature of Plate, extrude feature can't be mated, must be workplane
    Dim oBPlatePlane1 As WorkPlane
    Set oBPlatePlane1 = oSourceSubAsmOcc.Definition.WorkPlanes.Item(3)
    Debug.Print oBPlatePlane1.Name
    
'Get the face feature of the cover plate
    Dim oFaceFeature As PartFeature
    Set oFaceFeature = oTargetSubAsmOcc.Definition.Features.FaceFeatures(1)
    Debug.Print oFaceFeature.Name
    
'Proxy for the top of tank plate
    Dim oTargetSubAsmOccProx As FaceFeatureProxy
    Call oTargetSubAsmOcc.CreateGeometryProxy(oFaceFeature, oTargetSubAsmOccProx)
    Debug.Print oTargetSubAsmOccProx.Name
    
'Workplane for the top of the tank plate
    Dim oCovPlane2 As WorkPlane
    Set oCovPlane2 = oTargetSubAsmOcc.Definition.WorkPlanes.Item(3)
    Debug.Print oCovPlane2.Name
        
'workplane proxies
    Dim oAsmPlane1 As WorkPlaneProxy
    Call oSourceSubAsmOcc.CreateGeometryProxy(oBPlatePlane1, oAsmPlane1)
    Debug.Print oAsmPlane1.Name
    
    Dim oAsmPlane2 As WorkPlaneProxy
    Call oTargetSubAsmOcc.CreateGeometryProxy(oCovPlane2, oAsmPlane2)
    Debug.Print oAsmPlane2.Name
    
'Mate function
    Call oAsmCompDef.Constraints.AddMateConstraint(oAsmPlane1, oAsmPlane2, 0.375)

end sub

 

But now it keeps giving me the method of mate has failed.  I have both XY planes in proxy (even though I need to actually pick the cover plate face), but it won't attach them.  Can anyone help?  I've been stuck for days on this.

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

Post to forums  

Autodesk Design & Make Report