Problems with Sketch Relations (Constraints) - Diameter Dimension

A Part drawing is open,

A Sketch is active.

The sketch contains a circle.

The circle is selected.

I can't add a diameter dimension using any of the following methods

1. RelationManager.AddRelation(arrayOfObjects, swConstraintType_DIAMETER)
2. ModelDoc2.SketchAddConstraints("sgDIAMETER")

Is this a known limitation / bug or am I missing something?

 

Hello nirantar.vigyarthee,

What is your solidworks version?

I have 2020 SP4.

I don't know this problem. Give me a capture of your screen please, and I need know your document option, for help you.

Thank you.

AR.

 


2022-08-22_134816.jpg

Be careful @A.R  , it may be specific to Solidwatch (which I don't know).

1 Like

May be I should have explicitly mentioned that this is API (programming) related problem.

I am able to create dimension but the mentioned methods do not work.

Maybe look at this : https://help.solidworks.com/2020/english/api/sldworksapi/Constrain_Sketch_Example_VB.htm

1 Like

Thanks Sylk. I have already seen that. It does not include Dia Dimension.

Not sure what the sgDIAMETER is supposed to do, but it looks like a reserved word without any effect for now...

However, maybe this code below will doing what you want? :

Dim swApp As Object
Dim Part As Object
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long

Sub main()

Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc

boolstatus = Part.Extension.SelectByID2("Arc1", "SKETCHSEGMENT", 0, 0, 0, False, 0, Nothing, 0)
Dim myDisplayDim As Object
Set myDisplayDim = Part.AddDimension2(0, 0, 0)
Part.ClearSelection2 True

End Sub

gold

Dim swApp As Object
Dim Part As Object
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long

Sub main()

Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc

Dim myDisplayDim As Object

boolstatus = Part.Extension.SelectByID2("Arc1", "SKETCHSEGMENT", 0, 0, 0, False, 0, Nothing, 0)
Set myDisplayDim = Part.AddDimension2(0, 0, 0)

boolstatus = Part.Extension.SelectByID2("Arc2", "SKETCHSEGMENT", 0, 0, 0, False, 0, Nothing, 0)
Set myDisplayDim = Part.AddDimension2(0, 0, 0)

Part.ClearSelection2 True

End Sub

 

1 Like

Thanks. I already used that method. I just wanted to confirm that the two mentioned methods do not work or I was missing something.