Select an element and check its file name.....

Is there any way to select an element using the element selection tool and check its file name using vba code?

Parents
  • An element lives in a model.  A model lives in a DGN file.

    If the element is selected, then it's in a selection set. Look at the Select Set Example in VBA Help for some code.

    An element has a ModelReference property.  A ModelReference has a DesignFile property.  A DesignFile has a Path property.  So, once you've found your element, you can get its file name like this:

     Dim oElement As Element
    ... get element from selection set
    Dim fileName As String
    fileName = oElement.ModelReference.DesignFile.Path
    Debug.Print "Element file: '" & fileName & "'"

     
    Regards, Jon Summers
    LA Solutions

Reply
  • An element lives in a model.  A model lives in a DGN file.

    If the element is selected, then it's in a selection set. Look at the Select Set Example in VBA Help for some code.

    An element has a ModelReference property.  A ModelReference has a DesignFile property.  A DesignFile has a Path property.  So, once you've found your element, you can get its file name like this:

     Dim oElement As Element
    ... get element from selection set
    Dim fileName As String
    fileName = oElement.ModelReference.DesignFile.Path
    Debug.Print "Element file: '" & fileName & "'"

     
    Regards, Jon Summers
    LA Solutions

Children