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.
<p>Dim pid1 as string</p><p>pid1 = "xxxxxxxx <Long PID here>"</p><p></p><p>Set Swobj = GetObjectFromString(swApp, Part, pid1)</p><p> If Not Nothing Is Swobj Then</p><p> Dim swSelMgr As SldWorks.SelectionMgr</p><p> Dim seldat As SelectData</p><p> Set swSelMgr = Part.SelectionManager</p><p> Set seldat = swSelMgr.CreateSelectData</p><p> boolstatus = swSelMgr.AddSelectionListObject(Swobj, seldat)</p><p> Debug.Print boolstatus</p><p> Else</p><p> Debug.Print " ModelDocExtension::GetObjectByPersistReference3 broken"</p><p> End If</p><p>Function GetObjectFromString(swApp As SldWorks.SldWorks, swModel As SldWorks.ModelDoc2, IDstring As String) As Object</p><p> Dim swModExt As SldWorks.ModelDocExtension</p><p> Dim ByteStream() As Byte</p><p> Dim vPIDarr As Variant</p><p> Dim nRetval As Long</p><p> Dim i As Long</p><p> Set swModExt = swModel.Extension</p><p> ReDim ByteStream(Len(IDstring) / 3 - 1)</p><p> For i = 0 To Len(IDstring) - 3 Step 3</p><p> ByteStream(i / 3) = CByte(Mid(IDstring, i + 1, 3))</p><p> Next i</p><p> vPIDarr = ByteStream</p><p> Set GetObjectFromString = swModExt.GetObjectByPersistReference3((vPIDarr), nRetval)</p><p> Debug.Assert swPersistReferencedObject_Ok = nRetval</p><p> Debug.Assert Not GetObjectFromString Is Nothing</p><p>End Function</p>
Is there something I am missing?
SolidworksApi macros