Reply

AddLoftedFlange in SheetMetal

[ Edited ]

 

I need to be generate a Lofted Flanges (AddLoftedFlange) in Solid Edge's Sheet Metal environment. The documentation simply does not give enough information as to what the parameters are.

I have been able to generate a Lofted Protrution (AddLoftedProtrution) in the Part environment. Most of the parameters are similar.

Can someone help me with a working example of the AddLoftedFlange method?

 

 

 

Posted by: Curt Nisly
Post date: 6/12/2009 6:47:58 AM

4 REPLIES

RE: AddLoftedFlange in SheetMetal

[ Edited ]

 

Here is the code the DOESN'T work...

 

____________

Imports SolidEdgeConstants

Imports System.Runtime.InteropServices

 

Module Module1

Sub Main()

Dim objApplication As SolidEdgeFramework.Application = Nothing

Dim objDocuments As SolidEdgeFramework.Documents = Nothing

Dim objSheetMetal As SolidEdgePart.SheetMetalDocument = Nothing

Dim objSketches As SolidEdgePart.Sketchs = Nothing

Dim objSketch As SolidEdgePart.Sketch = 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

Dim Y1 As Double = 0

Dim X2 As Double = 0.2

Dim Y2 As Double = 0.2

 

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 sheet metal document

objSheetMetal = objDocuments.Add("SolidEdge.SheetMetalDocument")

' Get a reference to the reference planes collection

objRefplanes = objSheetMetal.RefPlanes

' Add a reference plane

objRefplane4 = objRefplanes.AddParallelByDistance(objRefplanes(1), 0, SolidEdgePart.ReferenceElementConstants.igNormalSide, , , False)

' Get a reference to the sketches collection

objSketches = objSheetMetal.Sketches

' Add a new sketch

objSketch = objSketches.Add()

' Get a reference to the sketch's profiles collection

objProfiles = objSketch.Profiles

' Add a new profile

objProfile1 = objProfiles.Add(objRefplane4)

' Get a reference to the lines2d collection

objLines2d = objProfile1.Lines2d

' Draw a profile

objLine2d = objLines2d.AddBy2Points(X1, Y1, X2, Y2)

' Show the profile

objProfile1.Visible = True

 

' Add a reference plane

objRefplane5 = objRefplanes.AddParallelByDistance(objRefplanes(1), 0.2, SolidEdgePart.ReferenceElementConstants.igNormalSide, , , False)

' Add a new sketch

objSketch = objSketches.Add()

' Get a reference to the sketch's profiles collection

objProfiles = objSketch.Profiles

' Add a new profile

objProfile2 = objProfiles.Add(objRefplane5)

' Get a reference to the lines2d collection

objLines2d = objProfile2.Lines2d

' Draw the Base Profile

objLine2d = objLines2d.AddBy2Points(X1, Y1, X2, Y2)

' Show the profile

objProfile2.Visible = True

 

' Get a reference to the models collection

objModels = objSheetMetal.Models

' Create the lofted flange

 

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.AddLoftedFlange(NumSections:=2, _

                                                 CrossSections:=objCSArray, _

                                                 CrossSectionTypes:=lngCSTypeArray, _

                                                 Origins:=objOrigins, _

                                                 OriginRefs:=0, _

                                                 ThicknessSide:=SolidEdgePart.FeaturePropertyConstants.igLeft, _

                                                 varRadius:=0.01, _

                                                 varNeutralFactor:=0.5, _

                                                 varBnParamType:=SolidEdgePart.FeaturePropertyConstants.igNFType)

 

 

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 (objSheetMetal Is Nothing) Then

Marshal.ReleaseComObject(objSheetMetal)

objSheetMetal = 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

 

____________

Here is the message:

The server threw an exception. (Exception from HRESULT: 0x80010105 (RPC_E_SERVER

FAULT))

 

Thanks,

Curt

 

Posted by: Curt Nisly
Post date: 6/13/2009 7:14:25 AM

RE: AddLoftedFlange in SheetMetal

[ Edited ]

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

 

Posted by: Curt Nisly
Post date: 6/13/2009 8:03:10 AM

RE: AddLoftedFlange in SheetMetal

[ Edited ]

This code works!

 

___________

Option Explicit

 

Dim objApp As SolidEdgeFramework.Application

Dim objDoc As SolidEdgePart.SheetMetalDocument

Dim objCSections(1 To 2) As Object

Dim cSectionTypes(1 To 2) As Long

Dim sectionOrigins(1 To 2) As Object

Dim sectionOriginRefs(1 To 2) As Long

Dim varRad As Double

Dim varNF As Double

Dim varBPType As Long

Dim loftflange As Object

 

Private Sub Form_Load()

 

Set objApp = GetObject(, "SolidEdge.Application")

Set objDoc = objApp.ActiveDocument

 

'Assume that the file contains two cross section sketches

 

'Set profile array

Set objCSections(1) = objDoc.Sketches(1).Profiles(1)

Set objCSections(2) = objDoc.Sketches(2).Profiles(1)

 

cSectionTypes(1) = igProfileBasedCrossSection

cSectionTypes(2) = igProfileBasedCrossSection

 

'set start point array

Set sectionOrigins(1) = objDoc.Sketches(1).Profiles(1).Arcs2d(1)

Set sectionOrigins(2) = objDoc.Sketches(2).Profiles(1).Arcs2d(1)

 

sectionOriginRefs(1) = igStart

sectionOriginRefs(2) = igStart

 

varRad = 1

varNF = 0.5

varBPType = igNFType

 

' side can be igLeft or igRight

Set loftflange = objDoc.Models.AddLoftedFlange( _

2, _

objCSections, _

cSectionTypes, _

sectionOrigins, _

sectionOriginRefs, _

igLeft, _

varRad, _

varNF, _

varBPType)

 

Set loftflange = Nothing

Set sectionOrigins(1) = Nothing

Set sectionOrigins(2) = Nothing

Set objCSections(1) = Nothing

Set objCSections(2) = Nothing

Set objDoc = Nothing

Set objApp = Nothing

 

End Sub

 

Posted by: Curt Nisly
Post date: 6/13/2009 8:31:04 AM

RE: AddLoftedFlange in SheetMetal

[ Edited ]

Could somebody please provide me with a complete example of Curt's previous post. I'm hung up on his "'Assume that the file contains two cross section sketches" comment. I need this example but I also need it to create all of the necessary objects via code rather than assuming that a file is open.

 

Can anyone please help? I'm working on the SDK and need a good example. Please and thank you!

 

Posted by: Jason Newell
Post date: 8/18/2010 11:33:56 PM