Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

AutoLisp ssget, Help needed

0 views
Skip to first unread message

Olle Skalare

unread,
Sep 3, 1995, 3:00:00 AM9/3/95
to
It would be great if anyone could help me with this problem:

I need to do an <ssget "x"> on all objects in a drawing with the
appname "APPNAME". How do i form the list?


((-1 . <Entity name: 89e709c8>) (0 . "INSERT") (5 . "23C9") (100
"AcDbEntity") (67 . 0) (8 . "LAYER_1") (100 . "AcDbBlockReference") (66
1)
(2 . "BERK206") (10 8680.0 -4400.0 0.0) (41 . 1.0) (42 . 1.0) (43 . 1.0)
(50 .
0.0) (70 . 0) (71 . 0) (44 . 0.0) (45 . 0.0) (210 0.0 0.0 1.0) (-3
("APPNAME"
(1000 . ""))))

Ben Olasov

unread,
Sep 4, 1995, 3:00:00 AM9/4/95
to
In article <42d51r$a...@prometheus.algonet.se>,

Olle Skalare <oska...@algonet.se> wrote:
>I need to do an <ssget "x"> on all objects in a drawing with the
>appname "APPNAME". How do i form the list?
>
>
>((-1 . <Entity name: 89e709c8>) (0 . "INSERT") (5 . "23C9") (100
> "AcDbEntity") (67 . 0) (8 . "LAYER_1") (100 . "AcDbBlockReference") (66
> 1)
>(2 . "BERK206") (10 8680.0 -4400.0 0.0) (41 . 1.0) (42 . 1.0) (43 . 1.0)
>(50 .
>0.0) (70 . 0) (71 . 0) (44 . 0.0) (45 . 0.0) (210 0.0 0.0 1.0) (-3
>("APPNAME"
>(1000 . ""))))

I'm assuming you know that the EED in this entity data list isn't
correctly represented [e.g., you'd have (1002 . "{") preceding and
(1002 . "}") following your 1000 key pair] - and also assuming you're
creating properly formed EED on all the entities you want to select...

You can return the selection set containing only the entities that
match your EED criteria by using the EED_SS function below. Given a
previously defined selection set SS, a valid application name APPNAME
anda valid application key value APPKEY [in the form of a string],
(EED_SS SS APPNAME APPKEY) will return the selection set of entities
that have EED application key and value pairs matching APPNAME and
APPKEY.

You can try out EED_SS with the function C:EED-SS.

;;; --------- cut here ----------

;; File EED_SS.LSP Copyright (C) Ben Olasov 1995 ola...@cs.columbia.edu

;; EED_SS returns the intersection of selection set &SELSET
;; containing EED with appname &KEY and data value &VAL.
(defun eed_ss (&selset &key &val / ss-int eed_match)
(cond ((or (null &selset)
(= (sslength &selset) 0)) nil)
(T (setq ss-int (ssadd))
(defun eed_match (e)
(equal (eed_val e &key) &val))
(process_ss &selset '(if (eed_match ssn)
(ssadd ssn ss-int)))))
ss-int)

;; EED_VAL returns the EED value %VAL for EED appname %KEY.
(defun eed_val (%enm %key / %elist)
(if (setq %elist (eed2list %enm %key))
(car %elist)))

;; PROCESS_SS successively evaluates the actions in the quoted expression
;; OPERATIONS for each member entity of selection set SS.
;; ** NOTE ** the variable SSN is a global variable which must be
;; explicitly referenced in the OPERATIONS argument.
;;
(defun process_ss (ss operations / i ssl)
(if (and ss operations)
(progn (setq i -1
ssl (sslength ss))
(terpri)
(repeat ssl
(setq i (1+ i))
(princ (strcat "\rProcessing ss member "
(itoa (1+ i)) " of "
(itoa ssl)))
(setq ssn (ssname ss i))
(eval operations)))
(if (null ss)
(princ "\nprocess_ss: empty ss")
(princ "\nprocess_ss: can't eval operations"))))

;; Gets the extended entity data corresponding to the appstr from e1.
;; From AutoDesk (reformatted to save space).
(defun EED2LIST (e1 appstr / xd_list elist l1)
;; Get the XED for the given entity.
(setq l1 nil
elist (entget e1 (list appstr)))
;; Check whether it has any XED attached.
(if (setq xd_list (assoc -3 elist))
(progn (setq xd_list (cdr xd_list)) ; Strip the -3 from the list
(setq l1 (BUILD_XDLIST xd_list)))) l1)

;; Used by EED2LIST function to output XED in a list form.
;; (does not structure according to braces).
;; From AutoDesk (reformatted to save space).
(defun build_xdlist (xd_list / n t m first second l1)
(setq l1 '())
(foreach m xd_list
(foreach n m
(if (= (type n) 'LIST)
(progn (setq first (car n))
(setq second (cdr n))
(cond ((/= first 1002)
(setq l1 (cons second l1)))
(T nil))))))
(reverse l1))

(defun userstr (dflt prmpt / var) ;;DFLT and PRMPT are strings
(setq var (getstring t (if (and dflt (/= dflt ""))
(strcat prmpt " <" dflt ">: ")
(strcat prmpt ": "))))
(cond ((/= var "") var)
((and dflt (= var "")) dflt)
(T dflt)))


;; to test eed_ss
(defun c:eed-ss (/ selecset)
(setq eed-ss nil)
(prompt "\nSelect entities for EED screening: ")
(if (setq selecset (ssget))
(if (setq app-key
(strcase (userstr (if app-key app-key "*")
"\nApplication name to use as search filter")))
(progn (setq app-val
(strcase (userstr (if app-val app-val "*")
(strcat "\nEED value associated with appname "
app-key))))
(setq eed-ss (eed_ss selecset app-key app-val))
eed-ss)
(progn (prompt "\nInvalid appname: ")
(princ)))
(progn (princ "\nNo selection set!")
(princ)))
(if eed-ss
eed-ss
(princ)))

--
;Ben Olasov ola...@shadow.cs.columbia.edu
; b...@syska.com

Knut Hunstad

unread,
Sep 4, 1995, 3:00:00 AM9/4/95
to
>From: Olle Skalare <oska...@algonet.se>

>It would be great if anyone could help me with this problem:

>I need to do an <ssget "x"> on all objects in a drawing with the

>appname "APPNAME". How do i form the list?


>((-1 . <Entity name: 89e709c8>) (0 . "INSERT") (5 . "23C9") (100
> "AcDbEntity") (67 . 0) (8 . "LAYER_1") (100 . "AcDbBlockReference") (66
> 1)
>(2 . "BERK206") (10 8680.0 -4400.0 0.0) (41 . 1.0) (42 . 1.0) (43 . 1.0)
>(50 .
>0.0) (70 . 0) (71 . 0) (44 . 0.0) (45 . 0.0) (210 0.0 0.0 1.0) (-3
>("APPNAME"
>(1000 . ""))))


A little unclear question, I think, what is the included list supposed to
mean? If you want to get all objects with "APPNAME", simply use this list:

(-3)
(1000 . "APPNAME")

I'm no LISP racer, but I guess you can figure out the rest yourself?

Knut Hunstad
SINTEF Highway Engineering
Trondheim, Norway


0 new messages