Inventor Customization

Inventor Customization

Reply
Contributor
tom_wise
Posts: 15
Registered: ‎07-30-2007
Message 1 of 2 (175 Views)
Accepted Solution

Proxy / Subassembly / Sheet metal problem

175 Views, 1 Replies
12-21-2012 02:34 PM

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

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.

Contributor
tom_wise
Posts: 15
Registered: ‎07-30-2007
Message 2 of 2 (157 Views)

Re: Proxy / Subassembly / Sheet metal problem

01-03-2013 06:17 AM 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.

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.