Reply

Flange Object

[ Edited ]

I tried to write a macro to create with Sheetmetal document a plate with one fold using the Flange object but it failed.Can anybody help me to find the problem and make it work?

 

width = 400 / 1000

Length = 400 / 1000

 

' Create/get the application with specific settings

On Error Resume Next

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

Set objSMDoc = objApp.Documents.Add("SolidEdge.SheetmetalDocument")

If Err Then

Err.Clear

Set objApp = CreateObject("SolidEdge.Application")

Set objSMDoc = objApp.Documents.Add("SolidEdge.SheetmetalDocument")

objApp.Visible = True

Else

Set objSMDoc = objApp.ActiveDocument

End If

Set objModels = objSMDoc.Models

Set objRPlanes = objSMDoc.RefPlanes

Set objTabProfile = objSMDoc.ProfileSets.Add.Profiles.Add(objRPlanes(1))

Set objLines2d = objTabProfile.Lines2d

Set objLine1 = objLines2d.AddBy2Points(X1:=0, Y1:=0, X2:=Length, Y2:=0)

Set objLine2 = objLines2d.AddBy2Points(X1:=Length, Y1:=0, X2:=Length, Y2:=width)

Set objLine3 = objLines2d.AddBy2Points(X1:=Length, Y1:=width, X2:=0, Y2:=width)

Set objLine4 = objLines2d.AddBy2Points(X1:=0, Y1:=width, X2:=0, Y2:=0)

Set objRelations = objTabProfile.Relations2d

Call objRelations.AddKeypoint(objLine1, igLineEnd, objLine2, igLineStart)

Call objRelations.AddKeypoint(objLine2, igLineEnd, objLine3, igLineStart)

Call objRelations.AddKeypoint(objLine3, igLineEnd, objLine4, igLineStart)

Call objRelations.AddKeypoint(objLine4, igLineEnd, objLine1, igLineStart)

Call objRelations.AddVerticalAlign(objLine1, igLineMiddle, objLine3, igLineMiddle)

Call objRelations.AddHorizontalAlign(objLine4, igLineMiddle, objLine2, igLineMiddle)

lngStatus = objTabProfile.End(ValidationCriteria:=igProfileClosed)

If lngStatus 0 Then

MsgBox ("Profile not closed")

End If

Set objModel = objModels.AddBaseTab(Profile:=objTabProfile, ExtentSide:=igRight)

objTabProfile.Visible = False

' Check the status of Base Feature

Set objTabs = objModel.Tabs

Set objTab = objTabs(1)

If objTab.Status igFeatureOK Then

MsgBox ("Error in the Creation of Base tab object")

End If

Set objTabFaces = objTab.FacesByRay(Xorigin:=0, Yorigin:=0, Zorigin:=1, Xdir:=0, Ydir:=0, Zdir:=-1)

Set objTabFace = objTabFaces.Item(1)

Set objTabEdges = objTabFace.Edges

Set objTabEdge = objTabEdges.Item(1)

Set objFlange = objModel.Flanges.Add(pLocatedEdge:=objTabEdge, FlangeSide:=igRight, FlangeLength:=0.05)

 

 

Posted by: Cesar Gamboa
Post date: 3/17/2006 10:11:06 PM