PDM API Drawing Node
Posted: Tue Jun 07, 2022 3:45 pm
Hi everyone,
I frequently want to get a handle for the drawing of a specific part (or vice versa) in order to sync PDM variable values, but there doesn't seem to be a clean way to get a drawing hook (similar to the "Open Drawing" button for a given part) through API. Anyone want to tell me I'm wrong and there's an obvious way to do this?
For reference, I do have a functioning workaround of scanning the reference tree for immediate parent with a file extension of "slddrw" (shown below), so this isn't a blocker so much as a "why is it like this" question. It just feels like a circuitous and inefficient way to get something that should be simple - building the ref tree seems to take a long time, especially if you're processing multiple files - and I'm hoping someone on here has a better solution.
Thanks in advance for any suggestions!
I frequently want to get a handle for the drawing of a specific part (or vice versa) in order to sync PDM variable values, but there doesn't seem to be a clean way to get a drawing hook (similar to the "Open Drawing" button for a given part) through API. Anyone want to tell me I'm wrong and there's an obvious way to do this?
For reference, I do have a functioning workaround of scanning the reference tree for immediate parent with a file extension of "slddrw" (shown below), so this isn't a blocker so much as a "why is it like this" question. It just feels like a circuitous and inefficient way to get something that should be simple - building the ref tree seems to take a long time, especially if you're processing multiple files - and I'm hoping someone on here has a better solution.
Code: Select all
Function GetDrawingId(ByVal targetFile As IEdmFile17) As Integer
Dim drawingID As Integer = Nothing
Dim fPos As IEdmPos5 = targetFile.GetFirstFolderPosition
Dim folder As IEdmFolder12 = targetFile.GetNextFolder(fPos)
Dim refTree As IEdmReference11 = targetFile.GetReferenceTree(folder.ID)
Dim rPos As IEdmPos5
Dim refFile As IEdmFile17
Dim ext As String
rPos = refTree.GetFirstParentPosition2(0, False, EdmRefFlags.EdmRef_File)
Dim parentRef As IEdmReference11
While Not rPos.IsNull
parentRef = refTree.GetNextParent(rPos)
refFile = parentRef.File
ext = Right(refFile.Name, refFile.Name.Length - refFile.Name.LastIndexOf(".") - 1)
If ext.ToLower.Equals("slddrw") Then
drawingID = refFile.ID
Return drawingID
End If
End While
Return drawingID
End Function