Auto-dimension from part origin only in drawing views

Hello, I would like to know what would be the way to change the point of origin of the dimension using the Autodimension method? I want all dimensions to start from the origin of the part.

Option Explicit

Dim swApp As SldWorks.SldWorks
Dim Part As SldWorks.ModelDoc2

Dim longstatus As Long

Sub main()

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

    Dim views As Variant
    views = Array("Drawing View1", "Drawing View2", "Drawing View3", "Drawing View4", "Drawing View5", "Drawing View6", "Drawing View7", "Drawing View8")

    Dim i As Integer

    For i = 0 To 2
        
        ' Limpiar selecciĂłn
        Part.ClearSelection2 True
        
        ' Activar hoja
        Part.ActivateSheet "Sheet1"
        
        ' Activar vista
        Part.ActivateView views(i)
        
        ' seleccionar la vista
        Part.Extension.SelectByID2 views(i), "DRAWINGVIEW", 0, 0, 0, False, 0, Nothing, 0
        
        ' Ejecutar AutoDimension
        longstatus = Part.AutoDimension(1, 2, 1, 2, -1)

    Next i

End Sub

The API help describes how to specify the datum. Did you read it?

1 Like

I have but not really understand how to do so. Are you referring to this method : SetAxisPoints Method

No. The things you want for the datum need to be selected with proper mark values before you execute the AutoDimension command.

Do you know what selection marks are?

Do you know how to select things programmatically?

Sorry, not trying to be an a-hole, just trying to get a gauge for where you are in your API journey. If you haven’t done these two things yet, then just saying “selected with proper mark values” isn’t going to be beneficial to you…

No worries at all Josh, learning is what matters most here.

I do know how to select entities and have used selection marks before to force specific selections. If my reasoning is correct, the sequence should be: first define the selection mark, then select the origin using that mark as a filter, and finally call the AutoDimension method. Is that right?

The mark is not a filter… The mark is a numerical value that is assigned to the selection so that certain SW commands know what that specific selection is for. Again, please refer to the Remarks section of the API help for the AutoDimension method.

There are many different ways in the API to select things programmatically. Some of these allow you to specify the selection mark within the command. Some of them require you to create a SelectData object and populate its Mark property, and then use that SelectData object as an argument of the selection command. You can even use the SelectionManager to set or change the Mark for any already-selected item using SetSelectedObjectMark.

So… Somehow you need to programmatically select the part origin and give that selection the Mark value of swAutodimMarkOriginDatum.

thanks for the explanations, now time to get back to my code again !