Here is the code for AddLoftedProtution in Solid Edge Part. This DOES work. I am posting it because the parameters are very similar to the AddLoftedFlange in SheetMetal. __________ Imports SolidEdgeConstants Imports System.Runtime.InteropServices Module Module1 Sub Main() Dim objApplication As SolidEdgeFramework.Application = Nothing Dim objDocuments As SolidEdgeFramework.Documents = Nothing Dim objPart As SolidEdgePart.PartDocument = Nothing Dim objSketches As SolidEdgePart.Sketchs = Nothing Dim objSketch As SolidEdgePart.Sketch = Nothing 'Dim objProfileSets As SolidEdgePart.ProfileSets = Nothing 'Dim objProfileSet As SolidEdgePart.ProfileSet = Nothing Dim objProfiles As SolidEdgePart.Profiles = Nothing Dim objProfile1 As SolidEdgePart.Profile = Nothing Dim objProfile2 As SolidEdgePart.Profile = Nothing Dim objRefplanes As SolidEdgePart.RefPlanes = Nothing Dim objRefplane4 As SolidEdgePart.RefPlane = Nothing Dim objRefplane5 As SolidEdgePart.RefPlane = Nothing Dim objRelations2d As SolidEdgeFrameworkSupport.Relations2d = Nothing Dim objRelation2d As SolidEdgeFrameworkSupport.Relation2d = Nothing Dim objLines2d As SolidEdgeFrameworkSupport.Lines2d = Nothing Dim objLine2d As SolidEdgeFrameworkSupport.Line2d = Nothing Dim objModels As SolidEdgePart.Models = Nothing Dim objModel As SolidEdgePart.Model = Nothing Dim objCSArray(0 To 1) As SolidEdgePart.Profile Dim lngCSTypeArray(0 To 1) As Long Dim objOrigins(0 To 1) As Object Dim dblOrigin(0 To 1) As Double Dim X1 As Double = 0.1 Dim Y1 As Double = 0.1 Dim X2 As Double = 0.4 Dim Y2 As Double = 0.2 Dim X3 As Double = 0.3 Dim Y3 As Double = 0.5 Dim X4 As Double = 0.0 Dim Y4 As Double = 0.6 Try ' Connect to a running instance of Solid Edge objApplication = Marshal.GetActiveObject("SolidEdge.Application") ' Get a reference to the documents collection objDocuments = objApplication.Documents ' Create a new part document objPart = objDocuments.Add("SolidEdge.partDocument") ' Get a reference to the sketches collection objSketches = objPart.Sketches ' Add a new sketch objSketch = objSketches.Add() ' Get a reference to the profiles collection objProfiles = objSketch.Profiles ' objProfileSet.Profiles ' Get a reference to the ref planes collection objRefplanes = objPart.RefPlanes ' Add a new profile objProfile1 = objProfiles.Add(objRefplanes.Item(3)) ' Get a reference to the lines2d collection objLines2d = objProfile1.Lines2d ' Draw the Base Profile objLine2d = objLines2d.AddBy2Points(X1, Y1, X2, Y2) objLine2d = objLines2d.AddBy2Points(X2, Y2, X3, Y3) objLine2d = objLines2d.AddBy2Points(X3, Y3, X4, Y4) objLine2d = objLines2d.AddBy2Points(X4, Y4, X1, Y1) ' Define Relations among the Line objects to make the Profile closed objRelations2d = objProfile1.Relations2d objRelation2d = objRelations2d.AddKeypoint( _ objLines2d.Item(1), _ KeypointIndexConstants.igLineEnd, _ objLines2d.Item(2), _ KeypointIndexConstants.igLineStart) objRelation2d = objRelations2d.AddKeypoint( _ objLines2d.Item(2), _ KeypointIndexConstants.igLineEnd, _ objLines2d.Item(3), _ KeypointIndexConstants.igLineStart) objRelation2d = objRelations2d.AddKeypoint( _ objLines2d.Item(3), _ KeypointIndexConstants.igLineEnd, _ objLines2d.Item(4), _ KeypointIndexConstants.igLineStart) objRelation2d = objRelations2d.AddKeypoint( _ objLines2d.Item(4), _ KeypointIndexConstants.igLineEnd, _ objLines2d.Item(1), _ KeypointIndexConstants.igLineStart) ' Close the profile objProfile1.End(SolidEdgePart.ProfileValidationType.igProfileClosed) ' Show the profile objProfile1.Visible = True 'Add a new sketch objSketch = objSketches.Add() ' Get a reference to the profiles collection objProfiles = objSketch.Profiles ' objProfileSet.Profiles ' Add a new reference plane objRefplane5 = objRefplanes.AddParallelByDistance(objRefplanes.Item(3), 0.25, SolidEdgePart.ReferenceElementConstants.igNormalSide, , , False) ' Add a new profile objProfile2 = objProfiles.Add(objRefplane5) ' Get a reference to the lines2d collection objLines2d = objProfile2.Lines2d ' Draw the Profile objLine2d = objLines2d.AddBy2Points(X1, Y1, X2, Y2) objLine2d = objLines2d.AddBy2Points(X2, Y2, X3, Y3) objLine2d = objLines2d.AddBy2Points(X3, Y3, X4, Y4) objLine2d = objLines2d.AddBy2Points(X4, Y4, X1, Y1) ' Define Relations among the Line objects to make the Profile closed objRelations2d = objProfile2.Relations2d objRelation2d = objRelations2d.AddKeypoint( _ objLines2d.Item(1), _ KeypointIndexConstants.igLineEnd, _ objLines2d.Item(2), _ KeypointIndexConstants.igLineStart) objRelation2d = objRelations2d.AddKeypoint( _ objLines2d.Item(2), _ KeypointIndexConstants.igLineEnd, _ objLines2d.Item(3), _ KeypointIndexConstants.igLineStart) objRelation2d = objRelations2d.AddKeypoint( _ objLines2d.Item(3), _ KeypointIndexConstants.igLineEnd, _ objLines2d.Item(4), _ KeypointIndexConstants.igLineStart) objRelation2d = objRelations2d.AddKeypoint( _ objLines2d.Item(4), _ KeypointIndexConstants.igLineEnd, _ objLines2d.Item(1), _ KeypointIndexConstants.igLineStart) objProfile2.End( _ SolidEdgePart.ProfileValidationType.igProfileClosed) ' Show the profile objProfile2.Visible = True ' Get a reference to the models collection objModels = objPart.Models ' Create the lofted protrusion. dblOrigin(0) = X1 dblOrigin(1) = Y1 objOrigins(0) = dblOrigin dblOrigin(0) = X1 dblOrigin(1) = Y1 objOrigins(1) = dblOrigin objCSArray(0) = objProfile1 objCSArray(1) = objProfile2 lngCSTypeArray(0) = SolidEdgePart.FeaturePropertyConstants.igProfileBasedCrossSection lngCSTypeArray(1) = SolidEdgePart.FeaturePropertyConstants.igProfileBasedCrossSection objModel = objModels.AddLoftedProtrusion(NumSections:=2, _ CrossSections:=objCSArray, _ CrossSectionTypes:=lngCSTypeArray, _ Origins:=objOrigins, _ SegmentMaps:=0, _ MaterialSide:=SolidEdgePart.FeaturePropertyConstants.igLeft, _ StartExtentType:=SolidEdgePart.FeaturePropertyConstants.igNone, _ StartExtentDistance:=0, _ StartSurfaceOrRefPlane:=Nothing, _ EndExtentType:=SolidEdgePart.FeaturePropertyConstants.igNone, _ EndExtentDistance:=0, _ EndSurfaceOrRefPlane:=Nothing, _ StartTangentType:=SolidEdgePart.FeaturePropertyConstants.igNone, _ StartTangentMagnitude:=0, _ EndTangentType:=SolidEdgePart.FeaturePropertyConstants.igNone, _ EndTangentMagnitude:=0) Catch ex As Exception Console.WriteLine(ex.Message) Finally For x As Integer = 0 To 1 If Not (objCSArray(x) Is Nothing) Then Marshal.ReleaseComObject(objCSArray(x)) objCSArray(x) = Nothing End If If Not (objOrigins(x) Is Nothing) Then objOrigins(x) = Nothing End If Next If Not (objModel Is Nothing) Then Marshal.ReleaseComObject(objModel) objModel = Nothing End If If Not (objModels Is Nothing) Then Marshal.ReleaseComObject(objModels) objModels = Nothing End If If Not (objRelations2d Is Nothing) Then Marshal.ReleaseComObject(objRelations2d) objRelations2d = Nothing End If If Not (objLine2d Is Nothing) Then Marshal.ReleaseComObject(objLine2d) objLine2d = Nothing End If If Not (objLines2d Is Nothing) Then Marshal.ReleaseComObject(objLines2d) objLines2d = Nothing End If If Not (objRelation2d Is Nothing) Then Marshal.ReleaseComObject(objRelation2d) objRelation2d = Nothing End If If Not (objRefplanes Is Nothing) Then Marshal.ReleaseComObject(objRefplanes) objRefplanes = Nothing End If If Not (objRefplane4 Is Nothing) Then Marshal.ReleaseComObject(objRefplane4) objProfile1 = Nothing End If If Not (objRefplane5 Is Nothing) Then Marshal.ReleaseComObject(objRefplane5) objProfile1 = Nothing End If If Not (objProfiles Is Nothing) Then Marshal.ReleaseComObject(objProfiles) objProfiles = Nothing End If If Not (objProfile1 Is Nothing) Then Marshal.ReleaseComObject(objProfile1) objProfile1 = Nothing End If If Not (objProfile2 Is Nothing) Then Marshal.ReleaseComObject(objProfile2) objProfile1 = Nothing End If If Not (objProfiles Is Nothing) Then Marshal.ReleaseComObject(objProfiles) objProfiles = Nothing End If If Not (objSketch Is Nothing) Then Marshal.ReleaseComObject(objSketch) objSketch = Nothing End If If Not (objSketches Is Nothing) Then Marshal.ReleaseComObject(objSketches) objSketches = Nothing End If If Not (objPart Is Nothing) Then Marshal.ReleaseComObject(objPart) objPart = Nothing End If If Not (objDocuments Is Nothing) Then Marshal.ReleaseComObject(objDocuments) objDocuments = Nothing End If If Not (objApplication Is Nothing) Then Marshal.ReleaseComObject(objApplication) objApplication = Nothing End If End Try End Sub End Module |