API - MEP - Retrieve Side Function/Sketch Name

Hello everyone,

I'd like to grab the name of a sketch or sketch line that I dimensioned with the APIs and automatically add a comment on the dimension to it. 

In other words, I would like to put in my call number a predefined name according to the sketch and I select the call number with its name (in the form of "X-plan-DX@EsquisseX@Vue") to add my annotation to it. Unfortunately this dimension does not really correspond to the sketch line that I have to annotate, it is created in a somewhat random way or at least without the assurance that it is always the same. 

Is there a function in the API to retrieve the name of the function/sketch that the dimension snaps to?

 

Thank you for your help,

Kind regards

1 Like

Can you put a visual of what you have at the beginning and what you want at the end? 

So here's the idea:

I have on each side stitches with a reference (see 0° and 350°), these sides have a name in solidworks but I can't get the name of the function.

These function names have a match in an excel file. I would like to add the name of the stitching on each of the sides as well as the corresponding diameters. 

I hope it's clearer. 

Thank you


cuve_cotation_angulaire.jpg
1 Like

The names of the dimensions in a drawing are not fixed unless you always copy the same plan with the same part

 

Otherwise can the information be linked to the value of the odds?

 

EDIT: I think this link can bring a beginning of a solution because it loops on all sides http://help.solidworks.com/2016/english/api/sldworksapi/Get_Dimension_Values_in_Drawing_Example_VB.htm

A condition remains to be applied so that the rating with a value XX has a score for XX and YY a score YY

I think that the modification made on the previous link may correspond to your needs 

'This example shows how to get the values of the dimensions in a drawing.

'---------------------------------------------------------------------------
' Preconditions:
' 1. Open a drawing document.
' 2. Open the Immediate window.
'
' Postconditions: Inspect the Immediate window.
'---------------------------------------------------------------------------

Option Explicit

Sub main()

Dim swApp                       As SldWorks.SldWorks   
Dim swModel                     As SldWorks.ModelDoc2   
Dim swDraw                      As SldWorks.DrawingDoc   
Dim swView                      As SldWorks.View   
Dim swDispDim                   As SldWorks.DisplayDimension   
Dim swDim                       As SldWorks.Dimension   
Dim swAnn                       As SldWorks.Annotation   
    
    Dim swModelDocExt As SldWorks.ModelDocExtension
    Dim boolstatus As Boolean
 

    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc
    Set swDraw = swModel

    'Debug.Print "File = " & swModel.GetPathName

    Set swView = swDraw.GetFirstView

    Do While Not swView Is Nothing
        'Debug.Print'  View = ' & swView.Name

        Set swDispDim = swView.GetFirstDisplayDimension5

        Do While Not swDispDim Is Nothing
            Set swAnn = swDispDim.GetAnnotation
            Set swDim = swDispDim.GetDimension

            Debug.Print "      DimFullName                  = " & swDim.FullName
            Debug.Print "      Value                        = " & swDim.GetSystemValue2("")
            Debug.Print "      CalloutBelow                 = " & swDispDim.GetText(swDimensionTextCalloutBelow)

                Set swModelDocExt = swModel.Extension
                boolstatus = swModel.Extension.SelectByID2(swDim.FullName, "DIMENSION", 0, 0, 0, False, 0, Nothing, 0)
                boolstatus = swModelDocExt.EditDimensionProperties(0, 0, 0, "", "", True, 9, 2, True, 1, 1, "", "", True, "", "Text to replace", "", True, swThisConfiguration, "")
                swModel.ClearSelection2 True
            
            Set swDispDim = swDispDim.GetNext3

        Loop

        Set swView = swView.GetNextView

    Loop

End Sub

 

It's up to you to put conditions to put the corresponding text

No return?