I have object collection with browser nodes. I tried to add this collection to oDrawDoc.SelectSet.Multiple(oObjColl) but it failed. I know that brower node has method "DoSelect" but it works per browser node and not for multiple nodes at once. How should I "DoSelect" multiple nodes?
Solved! Go to Solution.
Solved by HideoYamada. Go to Solution.
Hello danilo.veljkovic,
Try make a ObjectCollection of the BrowserNode.NativeObject and SelectMultiple it.
Here is a sample code.
Sub test() Dim nodes As BrowserNodesEnumerator Dim node As BrowserNode Dim oc As ObjectCollection Set oc = ThisApplication.TransientObjects.CreateObjectCollection Set nodes = ThisApplication.ActiveDocument.BrowserPanes("PmDefault").TopNode.BrowserNodes For Each node In nodes Debug.Print TypeName(node.NativeObject) If TypeName(node.NativeObject) = "ExtrudeFeature" Then oc.Add node.NativeObject End If Next ThisApplication.ActiveDocument.SelectSet.SelectMultiple oc End Sub
Good luck!
Thank you for the reply.
I have oCompOcc from oObjOccColl object collection and I get Native object for each occurrence. oAsmBN is node I want to select sub-nodes within.
This is what I am doing with the code:
Dim oNativeBrowserNodeDef As NativeBrowserNodeDefinition Dim oTargetNode As BrowserNode Dim oCompOcc As ComponentOccurrence Dim oObjColl As ObjectCollection Set oObjColl = ThisApplication.TransientObjects.CreateObjectCollection For Each oCompOccEnum In oObjOccColl For Each oCompOcc In oCompOccEnum Set oNativeBrowserNodeDef = oAsmDoc.BrowserPanes.GetNativeBrowserNodeDefinition(oCompOcc) Set oTargetNode = oAsmBN.AllReferencedNodes(oNativeBrowserNodeDef).Item(1) Call oObjColl.Add(oTargetNode) Debug.Print oTargetNode.NativeObject.Name Next Next Call oDrawDoc.SelectSet.SelectMultiple(oObjColl)
Last line ends in "Method 'SelectMultiple' of object 'SelectSet failed" error message.
Can each item of oObjColl be added individually to SelectSet?
I don't understand exactly what you want to do, but
you shuld
Call oObjColl.Add(oTargetNode.NativeObject)
instead of
Call oObjColl.Add(oTargetNode)
, I think.
Best regards,
=====
Freeradical
Hideo Yamada
Hideo,
NativeObject, in my case, is Occurrence. But want to select browser node for given occurrence. Browser node has DoSelect method but I cannot use it because I want to select multiple browser nodes. Just like we use Ctrl+Click to select multiple browser nodes, like this:
My code is for drawing module of inventor.
Oh, drawing document...
As far as I know, there is no way to select the browse nodes in drawing document via SelectSet.
Because the object type of there nodes does not disclosed.
Sorry for not helping.
By the way, What will you do after selecting multiple browser nodes?
=====
Freeradical
Hideo Yamada
Selecting browser node will highlight components in drawing view based on certain search criteria.
How about a way to select all of drawing curves corresponding to the component instead of selecting browser nodes?
(It must be slow...)
I already made this code but, as you've said, it is slow ... so i thought to make it faster ...
Hello,
I have posted about this issue on Idea Board.
Please vote and comment more information!
Best Regards,
=====
Freeradical
Hideo Yamada
Finally I got it!
Option Explicit Private Declare PtrSafe Function GetKeyboardState Lib "user32" (pbKeyState As Byte) As Long Private Declare PtrSafe Function SetKeyboardState Lib "user32" (pbKeyState As Byte) As Long Private Const VK_CONTROL = &H11 Private keys(256) As Byte Private save As Byte Private Sub SetCtrlKey() GetKeyboardState keys(0) save = keys(VK_CONTROL) keys(VK_CONTROL) = &H80 SetKeyboardState keys(0) End Sub Private Sub ResetCtrlKey() keys(VK_CONTROL) = save SetKeyboardState keys(0) End Sub Private Sub SelectPartsLoop(nodes As BrowserNodesEnumerator) Dim node As BrowserNode Dim occ As ComponentOccurrence For Each node In nodes Set occ = Nothing On Error Resume Next Set occ = node.NativeObject On Error GoTo 0 If Not occ Is Nothing Then If Left(occ.Name, 3) = "JIS" Then node.DoSelect End If End If SelectPartsLoop node.BrowserNodes Next End Sub Sub SelectParts() Dim obj As Object Dim dDoc As DrawingDocument Set dDoc = ThisApplication.ActiveDocument Dim nodes As BrowserNodesEnumerator Set nodes = dDoc.BrowserPanes.Item("DlHierarchy").TopNode.BrowserNodes SetCtrlKey SelectPartsLoop nodes ResetCtrlKey End Sub
I found that BrowserNode.DoSelect kept already selected items when I held down the control key (yes, on physical keyboard).
So if the keyboard state is changed as a control key being pressed by Win32 API, DoSelect keeps last selecting.
The above code will select all occurrences whose name starts with "JIS" as shown in the screen capture.
How is this?
=====
Freeradical
Hideo Yamada
Can't find what you're looking for? Ask the community or share your knowledge.