Alright!
I think I have it!
I want to complete it with a window that asks what geometry and sizes etc to choose. But for version 0.1 this is alright!
' This assumes that it is a part document.
Dim oPartDoc As PartDocument
oPartDoc = ThisApplication.ActiveDocument
' a reference to the component definition.
Dim oCompDef As PartComponentDefinition
oCompDef = oPartDoc.ComponentDefinition
' a reference to the transient geometry object.
Dim oTG As TransientGeometry
oTG = ThisApplication.TransientGeometry
Dim doc = ThisApplication.ActiveDocument
Dim oLijn = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kSketchCurveLinearFilter, "Select a line")
Dim oPunt = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kSketchPointFilter, "Select Point")
' Create a work plane at the end of the 2D sketch.
Dim oWP As WorkPlane
oWP = oCompDef.WorkPlanes.AddByNormalToCurve(oLijn, oPunt)
oWP.Visible() = False
Dim oRadius
oDiameter = InputBox("What is the DIAMETER?", "Prompt user for dimensions", "0 ")
If oDiameter = 0
oDiameter = 10
End If
oRadius = oDiameter/20
' Create a sketch on the Workplane
oSketch = oCompDef.Sketches.Add(oWP)
oRefpunt = oSketch.AddByProjectingEntity(oPunt)
Dim oSketchCircle As SketchCircle
oSketchCircle = oSketch.SketchCircles.AddByCenterRadius(oRefPunt, oRadius)
oSketch.GeometricConstraints.AddCoincident(oRefPunt, oSketchCircle.CenterSketchPoint)
'oSketch.DimensionConstraints.AddDiameter(oSketchCircle.ContainingSketchBlock, 0 )
Dim DimC As DimensionConstraint
DimC = oSketch.DimensionConstraints.AddDiameter(oSketchCircle, oTG.CreatePoint2d(0, 1), False)
Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.
___________________________