TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: JohnK on September 15, 2003, 05:00:56 PM
-
This function will test to see if the user has something selected on the screen when your program takes control.
As featured in the afralisp news letter.
;;;===================================================================;
;;; Selected-p ;
;;;-------------------------------------------------------------------;
;;; This function will test to see if something is selected on screen ;
;;; ;
;;; Returns: T or nil ;
;;; ;
;;; Author: John Kaul ;
;;; ;
;;; Usage: (if (not (Slected-p)) ;
;;; (vlax-ename->vla-object (car (entsel)))) ;
;;;===================================================================;
(defun Slected-p ()
(and (cadr (ssgetfirst)))
)
...more to come.
-
Very nice John. You don't mind id I use that....... right? :D
;;; FUNCTION
;;; catchs any errors in selection process
;;; returns a valid VLA-OBJECT or nil
;;; *requires* 'Selected-p' by John Kaul
;;;
;;; ARGUMENTS
;;; none
;;;
;;; USAGE
;;; (setq obj (MST-Select-It))
;;;
;;; PLATFORMS
;;; 2000+
;;;
;;; AUTHOR
;;; Copyright© 2003 Mark S. Thomas
;;; mark.thomas@theswamp.org
;;;
;;; VERSION
;;; 1.0 Tue Sep 16, 2003 07:04:21
(defun MST-Select-It (/ obj)
(if
(vl-catch-all-error-p
(if
(not (Slected-p))
(setq obj
(vl-catch-all-apply
'vlax-ename->vla-object
(list (car (entsel)))
)
)
)
)
(setq obj nil)
)
obj
)
-
Sure. But i got another one for ya. (I was gonna wait to show you this, but ...)
;;;===================================================================;
;;; Get-EntSelcted ;
;;;-------------------------------------------------------------------;
;;; This function will offer a way for the programer to get an ;
;;; entity or entities already slected on the screen before the ;
;;; program took control. This program was intended for use in an ;
;;; ActiveX program. I have chosen not to use the "Pickfirst" method ;
;;; in accomplishing this task because I wanted a way to do this even ;
;;; if the "pickfirst" variable was toggled to zero. If no entity is ;
;;; currently selected on the screen, this function will prompt the ;
;;; end user to select an entity. ;
;;; ;
;;; Author: John Kaul ;
;;; ;
;;; Returns: Either previously selected entity, a selected entity, or ;
;;; a list of selected entities. ;
;;; ;
;;; Usage: (vlax-ename->vla-object (Get-EntSelcted)) ;
;;; ;
;;;-------------------------------------------------------------------;
;;; Version: 1.1 Added the ability to have more then one selected ;
;;; objects on the screen. ;
;;;===================================================================;
(defun Get-EntSelcted (/ x cntr xlength xlist)
(setq x (cadr (ssgetfirst)))
(if x (setq xlength (sslength x)))
(cond
((= xlength 1)
(setq x (ssname x 0))
(sssetfirst nil)
(redraw x 3))
((> xlength 1)
(setq cntr xlength)
(cond
((>= cntr 2)
(setq cntr (1- xlength))
(while (>= cntr 0)
(setq xlist (cons (ssname x cntr) xlist)
cntr (1- cntr)))
(foreach a xlist (progn (sssetfirst nil) (redraw a 3))))))
((= xlength nil)
(while (not (setq x (entsel "\nselect object: "))))
(setq x (car x))
(sssetfirst nil)
(redraw x 3)))
(if (= nil xlist) x xlist)
)
-
So I take it's not ready for general use.
2 lines selected
(setq a (vlax-ename->vla-object (Get-EntSelcted)))
; error: bad argument type: lentityp (<Entity name: 7ef5bd70> <Entity name: 7ef5bd68>)
:D
Or am I using it wrong?
2 lines selected
(Get-EntSelcted)
(<Entity name: 7ef5bd70> <Entity name: 7ef5bd68>)
guess I was :oops:
Ok, it's going in the tool box...
thanks 7
-
One question, is the name really supposed to be Get-EntSelcted ?
Sorry, but you know how that stuff bugs me :D
-
One question, is the name really supposed to be Get-EntSelcted ?
Sorry, but you know how that stuff bugs me :D
Yeah, that kinda bothers me too. ...I wish we had the source code so we can chage it.
:P
(Sorry, I had to do that.) Change it to what ever you want, that is just as i had it in my "junk file" so i can find it faster with a search.