Hi all,
I am having trouble adding dimensions in my sketch! Can anyone give me a
pointer?
The code I have so far:
*****
Private Sub GenerateVessel()
' Import the parameters from the Userform
Dim TT, VID As Double
VID = UserForm1.TextBox1.Value / 10
TT = UserForm1.TextBox2.Value / 10
THK = UserForm1.TextBox3.Value / 10
' Create a new part document, using the default part template.
Dim oPartDoc As PartDocument
Set oPartDoc = ThisApplication.Documents.Add(kPartDocumentObject,
ThisApplication.FileManager.GetTemplateFile(kPartDocumentObject))
' Set a reference to the component definition.
Dim oPartCompDef As PartComponentDefinition
Set oPartCompDef = ThisApplication.ActiveDocument.ComponentDefinition
' Create a new sketch.
Dim oSketch As Sketch
Set oSketch = oPartCompDef.Sketches.Add(oPartCompDef.WorkPlanes.Item(3))
' Set a reference to the transient geometry collection.
Dim oTransGeom As TransientGeometry
Set oTransGeom = ThisApplication.TransientGeometry
' Create the sketch points for the vessel shell
Dim oCoord(1 To 6) As Point2d
Set oCoord1 = oTransGeom.CreatePoint2d(0, 0)
Set oCoord2 = oTransGeom.CreatePoint2d(TT, 0)
Set oCoord3 = oTransGeom.CreatePoint2d(0, (VID / 2))
Set oCoord4 = oTransGeom.CreatePoint2d(TT, (VID / 2))
Set oCoord5 = oTransGeom.CreatePoint2d(0, (VID / 2) + THK)
Set oCoord6 = oTransGeom.CreatePoint2d(TT, (VID / 2) + THK)
' Create line between 2 point
Dim oLine(1 To 5) As SketchLine
Set oLine(1) = oSketch.SketchLines.AddByTwoPoints(oCoord3, oCoord4)
Set oLine(2) = oSketch.SketchLines.AddByTwoPoints(oLine(1).EndSketchPoint,
oCoord6)
Set oLine(3) = oSketch.SketchLines.AddByTwoPoints(oLine(2).EndSketchPoint,
oCoord5)
Set oLine(4) = oSketch.SketchLines.AddByTwoPoints(oLine(3).EndSketchPoint,
oLine(1).StartSketchPoint)
Set oLine(5) = oSketch.SketchLines.AddByTwoPoints(oCoord1, oCoord2)
' Add 2D Constrains to lines (not complete yet)
Call oSketch.GeometricConstraints.AddGround(oLine(1).StartSketchPoint)
Call oSketch.GeometricConstraints.AddHorizontal(oLine(1))
Call oSketch.GeometricConstraints.AddPerpendicular(oLine(1), oLine(2))
Call oSketch.GeometricConstraints.AddParallel(oLine(3), oLine(1))
Call oSketch.GeometricConstraints.AddVertical(oLine(4))
Call oSketch.GeometricConstraints.AddHorizontal(oLine(5))
' Add dimensions to lines (what am I doing wrong here? Or, what have I done
right?)
Dim AddTwoPointDistance As DimensionConstraints
Call
oSketch.DimensionConstraints.AddTwoPointDistance(oLine(1).StartSketchPoint,
oLine(1).EndSketchPoint, kHorizontalDim, oLine(5).StartSketchPoint, True)
' Create a profile.
Dim oProfile As Profile
Set oProfile = oSketch.Profiles.AddForSolid
' Create a base revolve, 360 degrees.
Call oPartCompDef.Features.RevolveFeatures.AddFull(oProfile, oLine(5),
kJoinOperation)
End Sub
*****