AnsweredAssumed Answered

vb,vba-->OK; VB.net-->fail

Question asked by Goggoo Goggoo on Dec 3, 2014
Latest reply on Dec 3, 2014 by Goggoo Goggoo

myFeature = Part.FeatureManager.InsertStructuralWeldment4("D:\BOM\rr.sldlfp", 1, True, vGroups)

 

vb,vba-->OK; VB.net-->fail

 

 

VB

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

Dim swApp As Object
Dim Part As Object
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long

Private Sub Command1_Click()

Set swApp = CreateObject("SldWorks.Application")

Set Part = swApp.ActiveDoc
boolstatus = Part.Extension.SelectByID2("Line1@MF", "EXTSKETCHSEGMENT", 0, 0, 0, False, 0, Nothing, 0)
Dim SkSeg As Object
Set SkSeg = Part.SelectionManager.GetSelectedObject5(1)
boolstatus = SkSeg.SelectChain(False, Nothing)
Dim myFeature As Object
Dim vGroups As Variant
Dim GroupArray() As Object
ReDim GroupArray(0 To 0) As Object
Dim Group1 As Object
Set Group1 = Part.FeatureManager.CreateStructuralMemberGroup()
Dim vSegement1 As Variant
Dim SegementArray1() As Object
Dim Segment As Object

For K = 1 To Part.SelectionManager.GetSelectedObjectCount2(-1)
            ReDim Preserve SegementArray1(0 To (K - 1))
            Set Segment = Part.SelectionManager.GetSelectedObject5(K)
            Set SegementArray1(K - 1) = Segment
Next

vSegement1 = SegementArray1
Group1.Segments = (vSegement1)
Group1.ApplyCornerTreatment = False
Group1.Angle = 3.14159265
Set GroupArray(0) = Group1
vGroups = GroupArray

Set myFeature = Part.FeatureManager.InsertStructuralWeldment4("D:\BOM\RR.sldlfp", 1, True, (vGroups))
Part.ClearSelection2 True

End Sub

 

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

 

VB.net

 

 

    Dim SwApp As SldWorks.SldWorks

    Dim Part As SldWorks.ModelDoc2

    Dim Draw As SldWorks.DrawingDoc

    Dim swSelMgr As SldWorks.SelectionMgr

 

        Part = SwApp.ActiveDoc
        boolstatus = Part.Extension.SelectByID2("Line1@MF", "EXTSKETCHSEGMENT", 0, 0, 0, False, 0, Nothing, 0)
        Dim SkSeg As SldWorks.SketchSegment
        SkSeg = Part.SelectionManager.GetSelectedObject5(1)
        SkSeg.SelectChain(False, Nothing)
        Dim myFeature As Object
        Dim vGroups As System.Object
        Dim GroupArray(0 To 0) As System.Object
        Dim Group1 As SldWorks.StructuralMemberGroup
        Group1 = Part.FeatureManager.CreateStructuralMemberGroup()
        Dim vSegement1 As System.Object
        Dim SegementArray1() As Object
        Dim Segment As Object

        For K = 1 To Part.SelectionManager.GetSelectedObjectCount2(-1)
            ReDim Preserve SegementArray1(0 To (K - 1))
            Segment = Part.SelectionManager.GetSelectedObject5(K)
            SegementArray1(K - 1) = Segment
        Next

        vSegement1 = SegementArray1
        Group1.Segments = (vSegement1)
       
        Group1.ApplyCornerTreatment = False
        Group1.Angle = 3.14159265

        GroupArray(0) = Group1

        vGroups = GroupArray

        myFeature = Part.FeatureManager.InsertStructuralWeldment4("D:\BOM\rr.sldlfp", 1, True, vGroups)

        Part.ClearSelection2(True)

Outcomes