Can anybody advise me?
In my LISP script I have a selectionset (created by 'ssadd' function). As a result, I want get objects from the selectionset selected in Autocad model space.
Is there any way to make it?
Thanks,
Michal
|
Can anybody advise me?
In my LISP script I have a selectionset (created by 'ssadd' function). As a result, I want get objects from the selectionset selected in Autocad model space.
Is there any way to make it?
Thanks,
Michal
Welcome to AUGI... Here is quick one :
M.R.Code:(defun c:ss ( / ss s1 ) (setq ss (ssadd)) (while (setq s1 (car (entsel "\nPick single object"))) (vl-catch-all-apply 'ssadd (list s1 ss)) ) (sssetfirst nil ss) (princ) )
Note : vl-catch-all-apply function catches error of ssadd function if s1 is nil and therefore while loop is ended. sssetfirst function selects and grips objects in model space - possible also in paper space...
Without having a more clear understanding of what it is you're trying to do... I personally would prefer some visual feedback so that I'd know which entities I've already selected:
** Note - The error handler simply accounts for highlighted objects, were the user to hit ESC.Code:(defun c:FOO ( / *error*) (defun *error* (msg) (cond ((not msg)) ; Normal exit ((member msg '("Function cancelled" "quit / exit abort")) ((lambda (i) (while (/= nil (setq e (ssname ss (setq i (1+ i))))) (redraw e 4))) -1)) ; <esc> or (quit) ((princ (strcat "\n** Error: " msg " ** ")))) ; Fatal error, display it (princ)) ((lambda (ss / e) (while (/= nil (setq e (car (entsel "\nSelect an entity: ")))) (setq ss (ssadd e ss)) (redraw e 3)) (sssetfirst nil ss)) (ssadd)) (*error* nil))
"How we think determines what we do, and what we do determines what we get."
Sincpac C3D ~ Autodesk Exchange Apps
Computer Specs:
Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000
What's wrong with the following?
Code:(sssetfirst nil (ssget))
"How we think determines what we do, and what we do determines what we get."
Sincpac C3D ~ Autodesk Exchange Apps
Computer Specs:
Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000
Returning objects?
Here are two functions that return object(s) not using ssadd, but allowing for the use of filters. One returns a list of objects that is really easy to use a foreach with and the secont is similar to entsel but allows the use of a filter for a single selection.
syntax
(selectobjects nil)
(selectobjects (list (cons 0 "insert")))
or
(selectobject nil)
(selectobject (list (cons 0 "insert")))
P-
Code:(defun SelectObjects (lstFilter / intCount lstReturn ssSelections) (vl-load-com) (if (setq ssSelections (ssget lstFilter)) (repeat (setq intCount (sslength ssSelections)) (setq intCount (1- intCount) lstReturn (cons (vlax-ename->vla-object (ssname ssSelections intCount)) lstReturn ) ) ) ) lstReturn ) (defun SelectObject (lstFilter / objReturn ssSelections) (vl-load-com) (if (setq ssSelections (ssget ":S:E" lstFilter)) (vlax-ename->vla-object (ssname ssSelections 0) ) ) )
AutomateCAD
´sssetfirst´ have been a function I was looking for.
Thanks