Message 1 of 2
Add dimensions To fully constrain the circle Using AddTwoPointDistance, i am not able to give the dimension to the circle
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Dim WorkPlaneAngle As Double = (45 / 180) * PI Dim ExtrusionRadius As Double = 50 ' Radius of the circle Dim Location_XDirection As String = 50 ' Distance from origin in X direction Dim Location_YDirection As String = 40 ' Distance from origin in Y direction Dim oDimPt As Point2d oDimPt = ThisApplication.TransientGeometry.CreatePoint2d(Location_XDirection, Location_YDirection) ' Get the component definition of the part Dim oCompDef As PartComponentDefinition oCompDef = ThisDoc.Document.ComponentDefinition ' Automatically select the Z axis Dim oAxis As WorkAxis oAxis = oCompDef.WorkAxes.Item("Z Axis") ' Automatically select the YZ plane Dim oPlane As WorkPlane oPlane = oCompDef.WorkPlanes.Item("YZ Plane") ' Create a new work plane at an angle to the YZ plane around the Z axis Dim oNewPlane As WorkPlane Try oNewPlane = oCompDef.WorkPlanes.AddByLinePlaneAndAngle(oAxis, oPlane, WorkPlaneAngle) Catch ex As System.Runtime.InteropServices.COMException MessageBox.Show("Error creating plane: " & ex.Message) End Try ' Create a new sketch on the new work plane Dim oSketch As PlanarSketch oSketch = oCompDef.Sketches.Add(oNewPlane) ' Draw a circle with a specified radius and center point Dim oTransGeom As TransientGeometry oTransGeom = ThisApplication.TransientGeometry Dim oCenterPoint As SketchPoint oCenterPoint = oSketch.SketchPoints.Add(oTransGeom.CreatePoint2d(Location_XDirection, Location_YDirection)) Dim oCircle As SketchCircle oCircle = oSketch.SketchCircles.AddByCenterRadius(oCenterPoint, ExtrusionRadius) 'Add dimensions To fully constrain the circle Using AddTwoPointDistance
' i am not able to give the dimension to the circle Dim oDimX As DimensionConstraint oDimX = oSketch.DimensionConstraints.AddTwoPointDistance(oCenterPoint, oSketch.OriginPoint, DimensionOrientationEnum.kHorizontalDim, oDimPt) Dim oDimY As DimensionConstraint oDimY = oSketch.DimensionConstraints.AddTwoPointDistance(oCenterPoint, oSketch.OriginPoint, DimensionOrientationEnum.kVerticalDim, oDimPt) Dim oDimRadius As DimensionConstraint oDimRadius = oSketch.DimensionConstraints.AddRadius(oCircle, oTransGeom.CreatePoint2d(Location_XDirection, Location_YDirection)) ' Create a profile Dim oProfile As Profile oProfile = oSketch.Profiles.AddForSolid 'Create an extrusion oExtrudeDef = oCompDef.Features.ExtrudeFeatures.CreateExtrudeDefinition(oProfile, kJoinOperation) oExtrudeDef.SetDistanceExtent(1, kNegativeExtentDirection) Dim oExtrude As ExtrudeFeature oExtrude = oCompDef.Features.ExtrudeFeatures.Add(oExtrudeDef)