TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Coder on March 23, 2013, 12:15:19 PM
-
Hello masters :wink:
Is there a way to convert the ssadd function into Visual Lisp ? I think the function vla-additems is the one but I don't know how to deal with it .
(setq ss (ssadd))
(if (setq sel (ssget))
(repeat (setq int (sslength sel))
(ssadd (ssname sel (setq int (1- int))) ss)
)
)
Many thanks in Advance .
-
Perhaps if you explain what you are trying to do.
(setq sel (ssget))
(setq ss sel)
If ss is an existing selection set.
(setq sel (ssget))
(defun ss->ss (ss1 ss2 / i ename)
(and (eq 'pickset (type ss1))(eq 'pickset (type ss2))
(setq i -1)
(while (setq ename (ssname ss1 (setq i (1+ i))))
(ssadd ename ss2)))
)
ss2
)
;; (setq ss (ssadd))
(setq ss (ss->ss sel ss))
-
Found this one by Peter Jamtgaard,
see if this is will be satisfy your needs:
; Written By: Peter Jamtgaard 2002
; This program will convert a Autolisp selection set into
; a named selection set that can be accessed by ActiveX
; or Visual Basic
(defun SS (SSET SSNAM / CNT EOBJ NEWSS SAFE SSET SSLST SSOBJ)
(setq CNT 0
SSOBJ (vla-get-selectionsets
(vla-get-activedocument
(vlax-get-acad-object)
)
)
)
(if (vl-catch-all-error-p
(vl-catch-all-apply
'(lambda (X) (setq NEWSS (vla-add X SSNAM)))
(list SSOBJ)
)
)
(progn
(vla-delete (vla-item SSOBJ SSNAM))
(setq NEWSS (vla-add SSOBJ SSNAM))
)
)
(if SSET
(progn
(setq SAFE (vlax-make-safearray vlax-vbObject (cons 0 (- (sslength
SSET) 1))))
(repeat (sslength SSET)
(setq EOBJ (vlax-ename->vla-object
(ssname SSET CNT)
)
CNT (1+ CNT)
)
(setq SSLST (cons EOBJ SSLST))
)
(vlax-safearray-fill SAFE SSLST)
(vla-additems NEWSS (variant SAFE))
)
)
(princ (strcat "\nYou have created a selection set called " SSNAM))
(prin1)
)
(princ "SS")
(prin1)
-
Thanks fixo .
Can you please explain the code for me ?
Regards
-
So that's what you are after.
Here is some old code from Jeff.
http://www.theswamp.org/index.php?topic=2133.msg27500#msg27500
http://www.theswamp.org/index.php?topic=5342.msg65947#msg65947
-
Hi,
Here's a simpler way to convert the active AutoLISP selection set to a COM/ActiveX one.
This method is the only one I use, most of the time I rather use AutoLISP selection sets or lists.
Visual LISP selection sets and safearrays are boring to use and tend to make LISP as verbose as VBA.
...
(vla-Delete ss
) ; <- a COM selection set have to be released after used )
-
Hello .
I have a few questions and hope that someone have willing to help me with them . :wink:
As posted by fixo .
(vl-catch-all-error-p
(vl-catch-all-apply '(lambda (x) (setq newss (vla-add x ssnam))) (list ssobj))
)
1- the ssobj is added to the named selection set argument ( ssnam ) .
and below in the same code , they deleted ssobj from the ssnam and after that they re-add it to the ssnam , this is odd to me ?
(vla-delete (vla-item ssobj ssnam))
(setq newss (vla-add ssobj ssnam)))
2- What's the meaning of variant function ?
(vla-additems newss (variant safe))
Many thanks in advance .
-
1 Yes' you're right
2. variant is comes from VitalLisp,
it's equial to 'vlax-make-variant' function in VisualLisp
-
1 Yes' you're right
2. variant is comes from VitalLisp,
it's equial to 'vlax-make-variant' function in VisualLisp
Thank you fixo for that clarification , it's very helpful . :)
Thanks to CAB and gile also .
Many thanks