Author Topic: File Name Split To List  (Read 3901 times)

0 Members and 1 Guest are viewing this topic.

hendie

  • Guest
File Name Split To List
« on: August 11, 2004, 10:54:36 AM »
Code: [Select]
(fnsplitl (getvar "dwgname"))

found while looking for something else ~ isn't that always the case ?

CADaver

  • Guest
Re: File Name Split To List
« Reply #1 on: August 11, 2004, 11:13:23 AM »
Quote from: hendie
Code: [Select]
(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???

hendie

  • Guest
File Name Split To List
« Reply #2 on: August 11, 2004, 11:16:56 AM »
looking for something to access autocad groups :sot:

CADaver

  • Guest
File Name Split To List
« Reply #3 on: August 11, 2004, 11:20:21 AM »
Quote from: hendie
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.

hendie

  • Guest
File Name Split To List
« Reply #4 on: August 11, 2004, 11:25:27 AM »
yup, those 'ur the groups in question... was there anything specific you're looking for ?

CADaver

  • Guest
File Name Split To List
« Reply #5 on: August 11, 2004, 11:36:11 AM »
Quote from: hendie
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.

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
File Name Split To List
« Reply #6 on: August 11, 2004, 11:41:04 AM »
good find hendie. very cool.
TheSwamp.org  (serving the CAD community since 2003)

hendie

  • Guest
File Name Split To List
« Reply #7 on: August 11, 2004, 11:45:37 AM »
Cadaver, I haven't had time to delve into it yet but you may find this post this post from Luis Esquivel interesting

I think Luis already covers most of what you need

CADaver

  • Guest
File Name Split To List
« Reply #8 on: August 11, 2004, 12:08:52 PM »
Quote from: hendie
Cadaver, I haven't had time to delve into it yet but you may find this post 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:

daron

  • Guest
File Name Split To List
« Reply #9 on: August 11, 2004, 02:47:09 PM »
I wrote these a while back. They might have some glitches, since they were written for a specific purpose, but they should still work.
Code: [Select]
(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))

CADaver

  • Guest
File Name Split To List
« Reply #10 on: August 11, 2004, 04:15:11 PM »
Geez, I haven't had a chance to look at Luis' stuff yet, thanks Daron.