asking for help
I want the x point in making the circle to be -1, but why does it always read 0 when the result is finished?
I want the result to be 13 from the edge, but it is always 14. Is there something wrong with my program?
and the diameter is 10.5mm but input radius is 6.5
' Setting SolidWorks variable to SolidWorks application
Set swApp = Application.SldWorks
' Creating new part document
defaultTemplate = swApp.GetUserPreferenceStringValue(swUserPreferenceStringValue_e.swDefaultTemplatePart)
Set swDoc = swApp.NewDocument(defaultTemplate, 0, 0, 0)
' Select Front Plane
boolStatus = swDoc.Extension.SelectByID2("Top Plane", "PLANE", 0, 0, 0, False, 0, Nothing, 0)
' Setting Sketch Manager
Set swSketchManager = swDoc.SketchManager
' Insert a new sketch
swSketchManager.InsertSketch True
' Create a rectangle
Set mySketchSegment = swSketchManager.CreateCircleByRadius((-1 / 1000), ((1 / 2 * panjang) - D2) / 1000, 0, C9 / 1000)
boolStatus = swSketchManager.CreateLinearSketchStepAndRepeat(1, 2, 0, (panjang - D4) / 1000, 0, 4.7123889803847, "", False, False, False, True, True)
vSketchLines = swSketchManager.Create3PointCenterRectangle(0, 0, 0, ((W5 / 2) / 1000), 0, 0, 0, (((panjang / 2)) / 1000), 0)
' Exit sketch mode
swSketchManager.InsertSketch False
' Perform Extrude
Set swFeatureManager = swDoc.FeatureManager
boolStatus = swDoc.Extension.SelectByID2("Sketch1", "SKETCH", 0, 0, 0, False, 0, Nothing, 0)
swFeatureManager.FeatureExtrusion2 True, False, False, 0, 0, TC / 1000, 0, False, False, False, False, _
0, 0, False, False, False, False, True, True, True, 0, 0, False
W5=25
Panjang=150
D2=47
D4=94
C9=6.5
' mm
Thankyou

It works fine on mine.
On a side note, CreateCircleByRadius is Obsolete, use IModelDoc2.CreateCircleByRadius2. Fully define your sketches, use IModelDoc2.SketchAddConstraints and/or IModelDoc2.SketchManager.
You may need to turn off swInputDimValOnCreate at the beginning of the macro and then turn it back on at the end of the macro.
'Turn off Input dimension value
swApplication.SetUserPreferenceToggle swUserPreferenceToggle_e.swInputDimValOnCreate, False
'Turn on Input dimension value
swApplication.SetUserPreferenceToggle swUserPreferenceToggle_e.swInputDimValOnCreate, True
It should not affect the result, but set/check what your document is rounding off to.
IModelDoc2.SetUserPreferenceIntegerValue swUserPreferenceIntegerValue_e.swUnitsLinearDecimalPlaces, vbPrimaryUnits
IModelDoc2.SetUserPreferenceIntegerValue swUserPreferenceIntegerValue_e.swUnitsDualLinearDecimalPlaces, vbSecondayUnits