Message 1 of 5
Making A L profile with face feature

Not applicable
08-20-2009
05:32 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I am new to using and making macro's
I have the folowing problem.
I am trying to make a macro that creates a Sheetmetal L-Profile.
3 parameters that I use in a form will create the shape.
But i am using a second face for the flange
The second face is flipped the wrong direction. so my dimensions aren't right.
I hope someone can help me
Here you have the code:
thanks
Private Sub Btn1_Click()
Dim dblL As Double
Dim dblB As Double
Dim dblF1 As Double
dblL = CDbl(TxtL.Text)
dblB = CDbl(TxtB.Text)
dblF1 = CDbl(TxtF1.Text)
'dblTh = CDbl(TxtTh.Text)
' Create a new sheet metal document, using the default sheet metal template.
Dim oSheetMetalDoc As PartDocument
Set oSheetMetalDoc = ThisApplication.Documents.Add(kPartDocumentObject, _
ThisApplication.FileManager.GetTemplateFile(kPartDocumentObject, , , "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}"))
' Set a reference to the component definition.
Dim oCompDef As SheetMetalComponentDefinition
Set oCompDef = oSheetMetalDoc.ComponentDefinition
' Set a reference to the sheet metal features collection.
Dim oSheetMetalFeatures As SheetMetalFeatures
Set oSheetMetalFeatures = oCompDef.Features
' Create a new sketch on the X-Y work plane.
Dim oSketch As PlanarSketch
Set oSketch = oCompDef.Sketches.Add(oCompDef.WorkPlanes.Item(3))
' Set a reference to the transient geometry object.
Dim oTransGeom As TransientGeometry
Set oTransGeom = ThisApplication.TransientGeometry
' Draw a 4cm x 3cm rectangle with the corner at (0,0)
Call oSketch.SketchLines.AddAsTwoPointRectangle( _
oTransGeom.CreatePoint2d(0, 0), _
oTransGeom.CreatePoint2d((dblL / 10), (dblB / 10)))
' Create a profile.
Dim oProfile As Profile
Set oProfile = oSketch.Profiles.AddForSolid
Dim oFaceFeatureDefinition As FaceFeatureDefinition
Set oFaceFeatureDefinition = oSheetMetalFeatures.FaceFeatures.CreateFaceFeatureDefinition(oProfile)
' Create a face feature.
Dim oFaceFeature As FaceFeature
Set oFaceFeature = oSheetMetalFeatures.FaceFeatures.Add(oFaceFeatureDefinition)
' Get the top face for creating the new sketch.
' We'll assume that the 6th face is the top face.
Dim oFrontFace As Face
Set oFrontFace = oFaceFeature.Faces.Item(4)
' Create a new sketch on this face, but use the method that allows you to
' control the orientation and orgin of the new sketch.
Set oSketch2 = oCompDef.Sketches.AddWithOrientation(oFrontFace, _
oCompDef.WorkAxes.Item(1), True, True, oCompDef.WorkPoints(1))
' Draw a 4cm x 3cm rectangle with the corner at (0,0)
Call oSketch2.SketchLines.AddAsTwoPointRectangle( _
oTransGeom.CreatePoint2d(0, 0), _
oTransGeom.CreatePoint2d(dblL / 10, dblF1 / 10))
' Create a profile.
Dim oProfile1 As Profile
Set oProfile1 = oSketch2.Profiles.AddForSolid
Dim oFaceFeatureDefinition1 As FaceFeatureDefinition
Set oFaceFeatureDefinition1 = oSheetMetalFeatures.FaceFeatures.CreateFaceFeatureDefinition(oProfile1)
' Create a face feature.
Dim oFaceFeature1 As FaceFeature
Set oFaceFeature1 = oSheetMetalFeatures.FaceFeatures.Add(oFaceFeatureDefinition1)
End Sub
Private Sub Label1_Click()
End Sub
Private Sub UserForm_Click()
End Sub Edited by: DennisVercauteren on Aug 20, 2009 12:36 PM
I am new to using and making macro's
I have the folowing problem.
I am trying to make a macro that creates a Sheetmetal L-Profile.
3 parameters that I use in a form will create the shape.
But i am using a second face for the flange
The second face is flipped the wrong direction. so my dimensions aren't right.
I hope someone can help me
Here you have the code:
thanks
Private Sub Btn1_Click()
Dim dblL As Double
Dim dblB As Double
Dim dblF1 As Double
dblL = CDbl(TxtL.Text)
dblB = CDbl(TxtB.Text)
dblF1 = CDbl(TxtF1.Text)
'dblTh = CDbl(TxtTh.Text)
' Create a new sheet metal document, using the default sheet metal template.
Dim oSheetMetalDoc As PartDocument
Set oSheetMetalDoc = ThisApplication.Documents.Add(kPartDocumentObject, _
ThisApplication.FileManager.GetTemplateFile(kPartDocumentObject, , , "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}"))
' Set a reference to the component definition.
Dim oCompDef As SheetMetalComponentDefinition
Set oCompDef = oSheetMetalDoc.ComponentDefinition
' Set a reference to the sheet metal features collection.
Dim oSheetMetalFeatures As SheetMetalFeatures
Set oSheetMetalFeatures = oCompDef.Features
' Create a new sketch on the X-Y work plane.
Dim oSketch As PlanarSketch
Set oSketch = oCompDef.Sketches.Add(oCompDef.WorkPlanes.Item(3))
' Set a reference to the transient geometry object.
Dim oTransGeom As TransientGeometry
Set oTransGeom = ThisApplication.TransientGeometry
' Draw a 4cm x 3cm rectangle with the corner at (0,0)
Call oSketch.SketchLines.AddAsTwoPointRectangle( _
oTransGeom.CreatePoint2d(0, 0), _
oTransGeom.CreatePoint2d((dblL / 10), (dblB / 10)))
' Create a profile.
Dim oProfile As Profile
Set oProfile = oSketch.Profiles.AddForSolid
Dim oFaceFeatureDefinition As FaceFeatureDefinition
Set oFaceFeatureDefinition = oSheetMetalFeatures.FaceFeatures.CreateFaceFeatureDefinition(oProfile)
' Create a face feature.
Dim oFaceFeature As FaceFeature
Set oFaceFeature = oSheetMetalFeatures.FaceFeatures.Add(oFaceFeatureDefinition)
' Get the top face for creating the new sketch.
' We'll assume that the 6th face is the top face.
Dim oFrontFace As Face
Set oFrontFace = oFaceFeature.Faces.Item(4)
' Create a new sketch on this face, but use the method that allows you to
' control the orientation and orgin of the new sketch.
Set oSketch2 = oCompDef.Sketches.AddWithOrientation(oFrontFace, _
oCompDef.WorkAxes.Item(1), True, True, oCompDef.WorkPoints(1))
' Draw a 4cm x 3cm rectangle with the corner at (0,0)
Call oSketch2.SketchLines.AddAsTwoPointRectangle( _
oTransGeom.CreatePoint2d(0, 0), _
oTransGeom.CreatePoint2d(dblL / 10, dblF1 / 10))
' Create a profile.
Dim oProfile1 As Profile
Set oProfile1 = oSketch2.Profiles.AddForSolid
Dim oFaceFeatureDefinition1 As FaceFeatureDefinition
Set oFaceFeatureDefinition1 = oSheetMetalFeatures.FaceFeatures.CreateFaceFeatureDefinition(oProfile1)
' Create a face feature.
Dim oFaceFeature1 As FaceFeature
Set oFaceFeature1 = oSheetMetalFeatures.FaceFeatures.Add(oFaceFeatureDefinition1)
End Sub
Private Sub Label1_Click()
End Sub
Private Sub UserForm_Click()
End Sub Edited by: DennisVercauteren on Aug 20, 2009 12:36 PM