I am having trouble selecting faces via their PID. I obtain the PIDs via the PID collector, but now am stuck at selecting the returned objects from the PID.
This is what I am trying right now with little success. My final goal is to make an intersection sketch using these selected faces. Right now, I use the Select by ID, but as expected am having issues getting the right faces.
Dim pid1 as string
pid1 = "xxxxxxxx <Long PID here>"
Set Swobj = GetObjectFromString(swApp, Part, pid1)
If Not Nothing Is Swobj Then
Dim swSelMgr As SldWorks.SelectionMgr
Dim seldat As SelectData
Set swSelMgr = Part.SelectionManager
Set seldat = swSelMgr.CreateSelectData
boolstatus = swSelMgr.AddSelectionListObject(Swobj, seldat)
Debug.Print boolstatus
Else
Debug.Print " ModelDocExtension::GetObjectByPersistReference3 broken"
End If
Function GetObjectFromString(swApp As SldWorks.SldWorks, swModel As SldWorks.ModelDoc2, IDstring As String) As Object
Dim swModExt As SldWorks.ModelDocExtension
Dim ByteStream() As Byte
Dim vPIDarr As Variant
Dim nRetval As Long
Dim i As Long
Set swModExt = swModel.Extension
ReDim ByteStream(Len(IDstring) / 3 - 1)
For i = 0 To Len(IDstring) - 3 Step 3
ByteStream(i / 3) = CByte(Mid(IDstring, i + 1, 3))
Next i
vPIDarr = ByteStream
Set GetObjectFromString = swModExt.GetObjectByPersistReference3((vPIDarr), nRetval)
Debug.Assert swPersistReferencedObject_Ok = nRetval
Debug.Assert Not GetObjectFromString Is Nothing
End Function
Is there something I am missing?