Projecting extruded slot center to another part in an assembly

Projecting extruded slot center to another part in an assembly

paranjothiCBQ2N
Explorer Explorer
318 Views
1 Reply
Message 1 of 2

Projecting extruded slot center to another part in an assembly

paranjothiCBQ2N
Explorer
Explorer

Hi,

I am trying to project center of hole features to another part with VBA. I was able to do it, but we also use extruded slots. I was able to project the holes using the hole center point property. Like wise is there any way to project the extruded slot center. I used this code from API help and modified for projecting hole centers.

Thanks in Advance.

Public Sub ProjectingAcrossParts()
    ' Set a reference to the assembly component definition.
    Dim oAsmCompDef As AssemblyComponentDefinition
    Set oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition

    ' Get references to two occurrences.
    ' This arbitrarily gets the first and second occurrence.
    Dim oOcc1 As ComponentOccurrence
    Set oOcc1 = oAsmCompDef.Occurrences.Item(1)

    Dim oOcc2 As ComponentOccurrence
    Set oOcc2 = oAsmCompDef.Occurrences.Item(2)

    ' Create a sketch on the first part.
    Dim oSketch1 As PlanarSketch
    Set oSketch1 = oOcc1.Definition.Sketches.Add(oOcc1.Definition.WorkPlanes(1))

    ' Set a reference to the transient geometry collection.
    Dim oTransGeom As TransientGeometry
    Set oTransGeom = ThisApplication.TransientGeometry

    ' Create a sketch line on the sketch.
    Dim oSketchLine1 As Object
    Set oSketchLine1 = oSketch1.SketchLines.AddByTwoPoints(oTransGeom.CreatePoint2d(0, 0), _
    oTransGeom.CreatePoint2d(4, 0))

    ' Because we need the sketch line in the context of the assembly
    ' we need to create a proxy for the sketch line. The proxy
    ' represents the sketch line in the context of the assembly.
    Dim oSketchLine1Proxy As Object
    Call oOcc1.CreateGeometryProxy(oSketchLine1, oSketchLine1Proxy)

    ' Create a sketch on the second part.
    Dim oSketch2 As PlanarSketch
    Set oSketch2 = oOcc2.Definition.Sketches.Add(oOcc2.Definition.WorkPlanes(1))

    ' Create a proxy for the sketch in the second part.
    Dim oSketch2Proxy As PlanarSketchProxy
    Call oOcc2.CreateGeometryProxy(oSketch2, oSketch2Proxy)

    ' Project the line in the sketch in the first
    ' part to the sketch in the second part
    Dim oSketchLine2Proxy As SketchLineProxy
    Set oSketchLine2Proxy = oSketch2Proxy.AddByProjectingEntity(oSketchLine1Proxy)
End Sub
0 Likes
319 Views
1 Reply
Reply (1)
Message 2 of 2

paranjothiCBQ2N
Explorer
Explorer

Hi,

I've explained my case with these pictures.image.pngimage.png

Anyone have ideas about this.

0 Likes