View Full Version : Pass vba selection set to lisp or command line?
KevinBarnett
2004-10-27, 10:06 AM
Hi Gang,
Does anybody know how to pass a named VBA selection set to lisp or the command line?
For example. There appears to be no VBA method equal to the BOUNDARY command. You would need this to specify a selection to represent a specific boundary set whilst executing the boundary command.
At the moment I am using this:
SelStBnd.Clear
SelStBnd.Select acSelectionSetAll, , , FilterType, FilterData
ThisDrawing.SendCommand _
"(setq ss (ssget " & Chr(34) & "x" & Chr(34) & " (list (cons 8 " & _
Chr(34) & FilterData(0) & Chr(34) & " ))))" & vbCr
where SelStBnd is named selection set and FilterData(0) is layer names
After using this ss is available for re-use at the command prompt as a selection set. But surely there is a "vla" subr to transfer the VBA selection set to a lisp/command prompt selection set, which would be quicker than selecting twice.
Thanks,
Kevin.
Ed Jobe
2004-10-27, 01:08 PM
I wrote a function to do that but, I'm not at work, so I can't give you the code directly. Here is a link to an adesk ng thread (http://discussion.autodesk.com/thread.jspa?messageID=2140242) where I've posted it before.
KevinBarnett
2004-10-27, 01:54 PM
Thanks Ed, but ... I'm still not clear.
The link jumped to http://discussion.autodesk.com/thread.jspa?messageID=2140242 which resolves sendcommand reference to a single entity by using its handle.
I'm looking at referring to a selection set (previously named and populated in VBA) with sendcommand. Or did I miss something? Thanks for your patience.
Cheers,
Kevin.
Ed Jobe
2004-10-27, 07:07 PM
You pass the entity to the function. A selection set is an object. Both have handles and will work with the (handent) function. You just need to modify the signature of the function to accept objects instead of entities. I would create a new function from this one.
KevinBarnett
2004-10-28, 05:36 AM
How do you get the handle of the selection set in VBA?
I tried this:
Sub try()
Dim ss As AcadSelectionSet
Dim ao As AcadObject
Set ss = ThisDrawing.SelectionSets.Add("Temp1")
ss.Clear
ss.SelectOnScreen
MsgBox ss.Handle '''' This causes error 438, object doesnt support this property or method
Set ao = ss ''' This causes error: Type mismatch
MsgBox ao.Handle
End Sub
Isnt there a "vla" that can get the activex named selection set and place it in a command/lisp type selection set - maybe something like (vla-get *selectionsets* "name")?
I'm really hoping you wont get frustrated with my simple questions. Thanks for your help.
Kevin.
Ed Jobe
2004-10-28, 01:00 PM
No, that's ok. I'm just out of town now and can't really help too much. If no one else can help, I hope you can wait till Monday when I get back.
jwanstaett
2004-10-29, 05:54 PM
If you run the ss.SelectOnScreen just be for the do the command
you can us (setq ss (ssget "P")) as your comand
KevinBarnett
2004-11-01, 05:32 AM
Not a on-screen selection. Check the very first post. Used:
SelStBnd.Clear
SelStBnd.Select acSelectionSetAll, , , FilterType, FilterData
in VBA to build the selection. In the program I am writing, the selection set is going to be referred to many times with SendCommand as a specific boundary selection set in the Boundary command (as boundary is not available in VBA). So far I have used (ssget "x" ... ) to re-select the selection set at the command prompt and store it in a lisp selection set. Then I simply use !ss (ss being the name of the variable containing the selection set) to re-use it.
The only part of the process I want to improve is the re-selecting - original named selection set in VBA then make the same selection set in lisp (in SendCommand). Hence the original posting of the question. Ed has indicated that it's possible to use the handle of the VBA selection set - that's the missing bit.
Cheers,
Kevin.
jwanstaett
2004-11-01, 03:15 PM
add this vlisp code to your system
It will get a VBA Selectionset by name and
return a Vlisp Selectionset
;(Vbass "SelectionsetNmae")
;This function will return the VBA Selectionset
; name = Selectionsetname
;By John W Anstaett 11/01/04
(defun Vbass(SSname / acadObject acadDocument myss myas myc vlss)
(setq acadObject (vlax-get-acad-object))
(setq acadDocument (vla-get-ActiveDocument acadObject))
(setq myss (VLA-GET-SELECTIONSETS acadDocument))
(setq myas (VLA-ITEM myss SSname))
(setq myc (vla-get-count myas))
(setq vlss (ssadd))
(setq myi 0)
(repeat myc
(progn
(setq myvb (vla-item myas myi))
(setq vlss (ssadd (vlax-vla-object->ename myvb) vlss))
(setq myi (+ myi 1))
)
)
(setq vlss vlss)
)
Ed Jobe
2004-11-01, 06:13 PM
Kevin,
It looks like vba doesn't expose the handle or the ObjectID of the ss obj. You will have to go with a workaround like John's.
KevinBarnett
2004-11-02, 06:04 AM
Thanks John!!!!!
Ed Jobe
2019-02-15, 04:23 PM
I wrote a function to do that but, I'm not at work, so I can't give you the code directly. Here is a link to an adesk ng thread (http://discussion.autodesk.com/thread.jspa?messageID=2140242) where I've posted it before.
Updated link is https://forums.autodesk.com/t5/visual-basic-customization/deleted-items/m-p/300072
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.