TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: hendie on August 11, 2004, 10:54:36 AM
-
(fnsplitl (getvar "dwgname"))
found while looking for something else ~ isn't that always the case ?
-
(fnsplitl (getvar "dwgname"))
found while looking for something else ~ isn't that always the case ?
Cool, how in the heck did you run across that???
-
looking for something to access autocad groups :sot:
-
looking for something to access autocad groups :sot:
Groups as in the GROUP command, keep me informed on that we use the snot out of 'em.
-
yup, those 'ur the groups in question... was there anything specific you're looking for ?
-
yup, those 'ur the groups in question... was there anything specific you're looking for ?
Right off the top, I'd like to add elements to a group, by just selecting the group on the screen, then the elements to add. With several GROUPs I sometimes have to list the group first to find out which one I need.
I'd also like to count 'em and list the count, like BCOUNT does for blocks. We use them often for assemblies, and rather thando a material take-off on individual pieces, I'd rather do one for the assembly, then state number of assemblies required.
Never really thought about programming any of this until just now.
-
good find hendie. very cool.
-
Cadaver, I haven't had time to delve into it yet but you may find this post (http://discussion.autodesk.com/thread.jspa?messageID=1104463) this post from Luis Esquivel interesting
I think Luis already covers most of what you need
-
Cadaver, I haven't had time to delve into it yet but you may find this post (http://discussion.autodesk.com/thread.jspa?messageID=1104463) this post from Luis Esquivel interesting
I think Luis already covers most of what you need
Oh crud, somethng new on my to-do list... sigh... I asked for it didn't I?
Thanks ... i think... :wink:
-
I wrote these a while back. They might have some glitches, since they were written for a specific purpose, but they should still work.
(defun grp-sel ()
(setq $acad (vlax-get-acad-object)
$doc (vla-get-activedocument $acad)
groups (vla-get-groups $doc)
count 0
)
(repeat (vla-get-count groups)
(setq groupitem (vla-item groups 0)
groupname (vla-get-name groupitem)
groupfirst (substr groupname 1 1)
count (1+ count)
)
(if (= groupfirst "*")
(vla-delete groupitem)
)
)
(setq cnt (vla-get-count groups)
count 0
group-str ""
)
(repeat cnt
(setq group-str (strcat group-str
(vla-get-name (vla-item groups count))
" "
)
cnt (1+ cnt)
count (1+ count)
)
)
(initget (vl-string-right-trim " " group-str))
)
(defun c:gea ()
(grp-sel)
(setq gn (getkword (strcat "Type Group name to Delete: " group-str
" or [Enter] to delete all: "
)
)
)
(if (= gn nil)
(vlax-for each groups
(vla-delete each)
)
(vla-delete (vla-item groups gn))
)
(princ)
)
;;;QUICK GROUP ROUTINES
(defun c:gs (/ -e gn gr tn tp)
(grp-sel)
(setq gn (getkword (strcat "\nType Group name to Make Selectable \n"
group-str
"\nor 'Enter' to Select Text: "
)
)
)
(if (= gn nil)
(setq tp (entsel "\nSelect Text for Group name Selectability: "
) ;_ ENTSEL
gr (entget (car tp))
tn (cdr (assoc 1 gr))
-e (substr tn 1 (- (strlen tn) 2))
gn (substr -e 6)
) ;_ SETQ
) ;_ IF
(command "-GROUP" "S" gn "Y")
(mst-release $doc)
(mst-release $acad)
(mst-release groups)
(princ)
) ;_ DEFUN
(defun mst-release (obj /)
(if
(= (type obj) 'vla-object)
(if (not (vlax-object-released-p obj))
(vlax-release-object obj)
)
)
)
(defun c:ga (/ a tp gr tn -e gn)
(grp-sel)
(setq gn (getkword (strcat "\nType Group name to Add to group "
group-str
"\nor 'Enter' to Select Text: "
)
)
)
(if (= gn nil)
(setq tp (car (entsel "\nSelect Text for Group name: "))
gr (entget tp)
tn (cdr (assoc 1 gr))
-e (substr tn 1 (- (strlen tn) 2))
gn (substr -e 6)
) ;_ SETQ
) ;_ IF
(setq count 0)
(while (/= gn (vla-get-name (setq sel-grp (vla-item groups count))))
(setq count (1+ count))
)
(vlax-for item sel-grp
(vla-highlight item :vlax-true)
)
(while (setq ent (car (entsel "\nSelect objects to add to group: ")))
(setq vla-object (vlax-ename->vla-object ent)
obj-array (vlax-make-safearray vlax-vbobject '(0 . 0))
)
(vlax-safearray-put-element obj-array 0 vla-object)
(setq var-array (vlax-make-variant obj-array))
(vla-appenditems sel-grp var-array)
(vlax-for item sel-grp
(vla-highlight item :vlax-true)
)
)
(vla-regen $doc acActiveViewport)
(mst-release $doc)
(mst-release $acad)
(mst-release groups)
(princ)
) ;_ DEFUN
Of course, Mark'll notice his release function in there. I suppose I could follow his lead and release them in a mapcar function. What would that be? (mapcar 'mst-release (list $doc $acad groups))
-
Geez, I haven't had a chance to look at Luis' stuff yet, thanks Daron.