Author Topic: Need help with XDATA  (Read 6284 times)

0 Members and 1 Guest are viewing this topic.

V-Man

  • Bull Frog
  • Posts: 343
  • I exist therefore I am! Finally Retired!
Need help with XDATA
« on: April 11, 2005, 01:57:42 PM »
I want to be able to write xdata to a lwpolyline. The problem is some of the data needs to be gathered first to apply to the xdata.

See below...

In this example.....

Code: [Select]

(setvar "cmdecho" 0) ;switch off command echo
(prompt "\nSelect the Pline to Add/Modify Xdata : ") ;prompt the user
(setq e (entget (car (entsel)) '("TEST"))) ;get the associative code list
(setq e1 (assoc -3 e)) ;get the xdata
(if (not e1) ;if there is no exdata
(progn ;do the following
(if (not (tblsearch "APPID" "TEST")) ;check if the application has been registered
(regapp "TEST") ;if not, register it
);if
(setq e1 '((-3 ("TEST"
 (1000 . "CP_TAG|SPACE")
 (1000 . "dde|041105|DRAWING1|E54B");<---THIS IS THE PROBLEM AREA
)))) ;create a default xdata list
(setq e (append e e1)) ;append to to the main list
(entmod e) ;modify the entity
);progn
);if
(setq e2 (assoc -3 e)) ;get the code -3 list
(setq e3 (car (cdr e2))) ;get the exdata list
(setq SIZ (cdr (nth 1 e3))) ;get the 1st line
(setq SIZ1 (cdr (nth 2 e3))) ;get the 2nd line
(setq NSIZ (cons 1000 SIZ)) ;construct a new  list
(setq NSIZ1 (cons 1000 SIZ1)) ;construct a new  list
(princ)


Above the problem area is made up of different components. For example.
the 041105 is part of the drirectory structure that needs to br pulled form the "dwgprefix"
the DRAWING1 is the drawing name that needs to be pulled from the "dwgname"
the E54B is the entity handle that needs to be pulled from selecting the lwpolyline.

All of the above needs to be captured and put into a list so that it will write xdata to the
lwpolyline if there is none.

Anyone know how to accomplish this?

Any help would be greatly apprecitated.

Thanks,
AutoCAD 9 - 2023, AutoCADMap 2008 - 2010, Revit 2012 - 2022, Autocad Civil 3D 2023

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Need help with XDATA
« Reply #1 on: April 11, 2005, 02:21:26 PM »
It looks like you have answered your own question.

To get the gewprefix part, simply set DWGPREFIX to a variable and parse the section you need. I am presuming the directory part is the same setup same for all drawings. If not, you will need to do a whole lot of error checking.
Code: [Select]

(setq dir (substr (getvar "DWGPREFIX") begin end))
(setq dwgname (getvar "DWGNAME"))
(setq hand (cdr (assoc 5 e)))

Then to put the data in:

Code: [Select]

(setq data (strcat "dde|" dir "|" dwgname "|" hand))
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

V-Man

  • Bull Frog
  • Posts: 343
  • I exist therefore I am! Finally Retired!
Need help with XDATA
« Reply #2 on: April 11, 2005, 03:04:09 PM »
I got that but how do I re-apply the finding into a list.. under the 1000 area?





Code: [Select]

(setq e1 '((-3 ("TEST"
 (1000 . "CP_TAG|SPACE")
 ;(1000 . "dde|041105|DRAWING1|E54B");<---THIS IS THE PROBLEM AREA
))))


Code: [Select]

(setq dwgprefix# (getvar "dwgprefix"))
(setq dir (substr dwgprefix# 20 6))
(setq dwgname (getvar "DWGNAME"))


(setq data (strcat "dde|" dir "|" dwgname "|" hand))
AutoCAD 9 - 2023, AutoCADMap 2008 - 2010, Revit 2012 - 2022, Autocad Civil 3D 2023

V-Man

  • Bull Frog
  • Posts: 343
  • I exist therefore I am! Finally Retired!
Need help with XDATA
« Reply #3 on: April 11, 2005, 04:53:53 PM »
Ok, I'm getting really close.


Code: [Select]

(defun c:ppp ()
(setvar "cmdecho" 0) ;switch off command echo
(prompt "\nSelect the Pline to Add/Modify Xdata : ") ;prompt the user
(setq e (entget (car (entsel)) '("CP_INFO"))) ;get the associative code list
(gdata)
(setq hand (cdr (assoc 5 e))) ;extract entity handle
(setq e1 (assoc -3 e)) ;get the xdata
(if (not e1) ;if there is no exdata
(progn ;do the following
(if (not (tblsearch "APPID" "CP_INFO")) ;check if the application has been registered
(regapp "CP_INFO") ;if not, register it
);if
(setq e1 '((-3 ("CP_INFO"
 (1000 . "CP_TAG|SPACE")
)))) ;create a default xdata list
(setq e (append e e1)) ;append to to the main list
(entmod e) ;modify the entity
;added
(setq e (append e getans)) ;append to to the main list
(entmod e) ;modify the entity
;added
);progn
);if
(setq e2 (assoc -3 e)) ;get the code -3 list
(setq e3 (car (cdr e2))) ;get the exdata list
(setq SIZ (cdr (nth 1 e3))) ;get the 1st line
(setq getans (cons 1000 data))
(setq SIZ1 (cdr (nth 2 e3))) ;get the 2nd line
(setq NSIZ (cons 1000 SIZ)) ;construct a new  list
(setq NSIZ1 (cons 1000 SIZ1)) ;construct a new  list
(princ)
)
(defun gdata ()
(setq dwgprefix# (getvar "dwgprefix"))
(setq dir (substr dwgprefix# 20 6))
(setq dwgname (getvar "DWGNAME"))
(setq hand (cdr (assoc 5 e)))
(setq data (strcat "dde|" dir "|" dwgname "|" hand))
(setq getans (cons 1000 data))
)




I'm getting the answer I need for the addition of the xdata but i'm having trouble with the formatting. The GETANS is the new addition that needs to be added but something is wrong. Any ideas?
AutoCAD 9 - 2023, AutoCADMap 2008 - 2010, Revit 2012 - 2022, Autocad Civil 3D 2023

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Need help with XDATA
« Reply #4 on: April 11, 2005, 04:55:06 PM »
you can always simply append the data, or substitute it in the data list.

For example, if your data has a 1000 group, you can use SUBST to change it, if it does not have one, use APPEND to append it to the list before you entmod the list.

I must admit though, I am a little confused .... I thought you asked how you could get that information to put into the list, not how do you modify a list already existing.... either way, that should solve your problem, unless of course I mave misunderstood once again.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

V-Man

  • Bull Frog
  • Posts: 343
  • I exist therefore I am! Finally Retired!
Need help with XDATA
« Reply #5 on: April 11, 2005, 05:13:46 PM »
Sorry if I'm confusing you. You are correct I am trying to make/add xdata not change.

I get this when I try to append the list

Command: !getans
(1000 . "dde|GA0121|GA0121-S-26.dwg|532")


getans hold the values I need but when I try to append I get the following error.

Command: (setq e (append e getans))
; error: bad list: "dde|GA0121|GA0121-S-26.dwg|532"
AutoCAD 9 - 2023, AutoCADMap 2008 - 2010, Revit 2012 - 2022, Autocad Civil 3D 2023

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Need help with XDATA
« Reply #6 on: April 11, 2005, 06:12:05 PM »
Ok, lets start by examining the XData list ... remember that XData itself is a list, and all of the subitems are part of the -3 list, so you have to operate on that list a little deeper that your variable "e" will allow with subst ....

Suppose your xdata list looked like this:
Quote

(-3 ("CP_INFO" (1000 . "CP_TAG|SPACE")))


If you used SUBST,  you would not be able to change the 1000 group because SUBST is looking for a the dotted pair (1000 . "CP_TAG|SPACE") ... This will not work because the dotted pair is actually the second part of the first "dotted pair" although in reality group -3 isn't dotted ... So .. to get to that deeper groupcode ...
Code: [Select]

;get the list including xdata
(setq e (entget (car (entsel))'("CP_INFO")))
;seperate out the xdata from the list
;using this method
(setq xd '((-3 ("CP_INFO" (1000 . "CP_TAG|SPACE")))))
;or this method
(setq xd (assoc -3 e))


Now that you have the list, if you don't need to keep the data that is in the list, you will simply recreate the new XData list and SUBST it back to the original list.

Code: [Select]

(setq newxd (list (cons -3 (cons "CP_INFO" (cons 1000 newdata)))))
(setq e1 (subst newxd xd e))
(entmod e1)


This should give your original list with the new data in the place of the old.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

V-Man

  • Bull Frog
  • Posts: 343
  • I exist therefore I am! Finally Retired!
Need help with XDATA
« Reply #7 on: April 18, 2005, 02:57:24 PM »
Ok, hopefully someone can shed some more light on this. I still can't get this...

Ok, I have this

Code: [Select]

(setq e1 '((-3 ("CP_INFO"
         (1001 . "CP_INFO")
 (1000 . "CP_TAG|SPACE")
))))


Command: !e1
((-3 ("CP_INFO" (1001 . "CP_INFO") (1000 . "CP_TAG|SPACE"))))




Now, I have this...




Code: [Select]

(defun gdata ()
(setq dwgprefix# (getvar "dwgprefix"))
(setq dir (substr dwgprefix# 20 6))
(setq dwgname (getvar "DWGNAME"))
(setq hand (cdr (assoc 5 e)))
(setq data (strcat "dde|" dir "|" dwgname "|" hand))
(setq newdata (cons 1000 data))
)


Command: !newdata
(1000 . "dde|GA0121|GA0121-S-26.dwg|47D")


Now, how do I take and either subst or append the NEWDATA to the E1???

So that I get this for 1 combined list

Code: [Select]

(1001 . "CP_INFO")
(1000 . "CP_TAG|SPACE")
(1000 . "dde|GA0121|GA0121-S-26.dwg|47D")



Help....

Thnx
AutoCAD 9 - 2023, AutoCADMap 2008 - 2010, Revit 2012 - 2022, Autocad Civil 3D 2023

Jimmy D

  • Guest
Need help with XDATA
« Reply #8 on: April 20, 2005, 08:11:39 AM »
Hi Dvarino,

Have a look at this modified routine.
I think the trick is that you should handle the whole -3 group
as one and subst this group from the selection.
So make a new list  (-3 ...new) and subst (-3...old).
(The new list here is xd)


Code: [Select]
(defun c:ppp ()
   (setvar "cmdecho" 0)               ;switch off command echo
   (prompt "\nSelect the Pline to Add/Modify Xdata : ")   ;prompt the user
   (setq e (entget (car (entsel)) '("CP_INFO")))      ;get the associative code list
   (gdata)
   (setq hand (cdr (assoc 5 e)))            ;extract entity handle
   (setq e1 (assoc -3 e))               ;get the xdata
   (if (not e1)                  ;if there is no exdata
   (progn                     ;do the following
      (if (not (tblsearch "APPID" "CP_INFO"))         ;check if the application has been registered
       (regapp "CP_INFO")            ;if not, register it
      );if      
      (setq e1 '((-3 ("CP_INFO"
                (1000 . "CP_TAG|SPACE")
      ))))                    ;create a default xdata list
      (setq e (append e e1))  ;append to to the main list
      (entmod e)              ;modify the entity
;added

     (setq xd (list "CP_INFO"))
     (setq xd (append xd (list (cons 1000 "CP_TAG|SPACE"))))
     (setq xd (append xd (list getans)))
     (setq xd (append xd (list (cons 1000 "Some more data"))))
     (setq xd (list -3 xd))
     (setq e (subst xd (car e1) e))
     (entmod e)

;added      
   );progn
   );if
   (setq e2 (assoc -3 e))               ;get the code -3 list
   (setq e3 (car (cdr e2)))            ;get the exdata list
   (setq SIZ (cdr (nth 1 e3)))            ;get the 1st line
   (setq getans (cons 1000 data))
   (setq SIZ1 (cdr (nth 2 e3)))            ;get the 2nd line
   (setq NSIZ (cons 1000 SIZ))            ;construct a new  list
   (setq NSIZ1 (cons 1000 SIZ1))            ;construct a new  list
   (princ)
)
(defun gdata ()
(setq dwgprefix# (getvar "dwgprefix"))
(setq dir (substr dwgprefix# 20 6))
(setq dwgname (getvar "DWGNAME"))
(setq hand (cdr (assoc 5 e)))
(setq data (strcat "dde|" dir "|" dwgname "|" hand))
(setq getans (cons 1000 data))
)



Hope this could help a bit.

Jimmy

V-Man

  • Bull Frog
  • Posts: 343
  • I exist therefore I am! Finally Retired!
Need help with XDATA
« Reply #9 on: April 20, 2005, 09:58:13 AM »
Ok, now that did work. Many thanks.

Question, I'm trying to modify this now to draw a BPOLY and then assign the XDATA to it instead of the user selectiing on an existing lwpolyline. No go so far.

Heres what I have

Code: [Select]

(defun c:ppp () ;( / e index e1 xd )
   (setvar "cmdecho" 0)               ;switch off command echo
 ;  (prompt "\nSelect the Pline to Add/Modify Xdata : ")   ;prompt the user
 ;  (setq e (entget (car (entsel)) '("CP_INFO")))      ;get the associative code list
;;added
   (setq SS1 (ssadd))
   (command ".bpoly")
   (ssadd (entlast) SS1)
   (setq index 0)
   (setq e (entget (ssname SS1 index)))
;;added
   (gdata)
   (setq e1 (assoc -3 e))               ;get the xdata
   (if (not e1)                  ;if there is no exdata
   (progn                     ;do the following
      (if (not (tblsearch "APPID" "CP_INFO"))         ;check if the application has been registered
       (regapp "CP_INFO")            ;if not, register it
      );if        
      (setq e1 '((-3 ("CP_INFO"
                (1000 . "CP_TAG|SPACE")
      ))))                    ;create a default xdata list
      (setq e (append e e1))  ;append to to the main list
      (entmod e)              ;modify the entity
     (setq xd (list "CP_INFO"))
     (setq xd (append xd (list (cons 1000 "CP_TAG|SPACE"))))
     (setq xd (append xd (list getans)))
     ;(setq xd (append xd (list (cons 1000 "Some more data"))))
     (setq xd (list -3 xd))
     (setq e (subst xd (car e1) e))
     (entmod e)
   );progn
   );if
   (princ)
)
(defun gdata ( / dwgprefix# dir dwgname hand data getans)
(setq dwgprefix# (getvar "dwgprefix"))
(setq dir (substr dwgprefix# 20 6))
(setq dwgname (getvar "DWGNAME"))
(setq hand (cdr (assoc 5 e)))
(setq data (strcat "dde|" dir "|" dwgname "|" hand))
(setq getans (cons 1000 data))
)


It seems to be getting the wrong ehandle from the line instead of the lwpolyline.
AutoCAD 9 - 2023, AutoCADMap 2008 - 2010, Revit 2012 - 2022, Autocad Civil 3D 2023

Jimmy D

  • Guest
Need help with XDATA
« Reply #10 on: April 21, 2005, 01:35:51 AM »
Dvarino,

It's not entirely clear what you are trying to do.

Are you planning to make a selection of LWPOLYLINE's and attach XDATA to each one of them? When you use BPOLY more then one entity can be created.
If yes -> you have to make a selection set (as you did) and select each entity at a time and attach xdata (... (repeat (length SS1))...)
If no -> a simple ...(entlast)... will do and no selection set needs to be created.


Quote
(setq e1 (assoc -3 e))               ;get the xdata
           (if (not e1)                  ;if there is no exdata
           (progn.....


Because you want to attach xdata to a newly created object, you know (assoc -3 e) doesn't exist, so no need to find out if it does.

Quote
(setq e1 '((-3 ("CP_INFO"
                (1000 . "CP_TAG|SPACE")
           ))))                    ;create a default xdata list
          (setq e (append e e1))  ;append to to the main list
          (entmod e)    


There is no need to make a default xdata list, you create only one final xdata list and attach it to the entity.


Quote
(setq e (subst xd (car e1) e))


No need to subst the list (it doesn't exist yet), simply append the list to the entity.


I hope this can get you going again.
Give us a shout if not.

V-Man

  • Bull Frog
  • Posts: 343
  • I exist therefore I am! Finally Retired!
Need help with XDATA
« Reply #11 on: April 21, 2005, 08:19:58 AM »
Right, basically I would like the user to initiate the command for which the Bpoly command will start and the user selects internal to create the bpoly and from that I would like the xdata assigned to that particular lwpolyline according to the pertinent information (ehandle , drawing name etc..) and so on... etc.... and keep bpoly'ing until the user cancells the command. So i guess there needs to be a WHILE in there to keep the command going until cancelled.

Maybe another way that would be nice is say if all of the lwpolylines were already created, could the routiune gather up all of the lwpolylines and assign to each the same information until complete?
AutoCAD 9 - 2023, AutoCADMap 2008 - 2010, Revit 2012 - 2022, Autocad Civil 3D 2023

Jimmy D

  • Guest
Need help with XDATA
« Reply #12 on: April 21, 2005, 08:23:51 AM »
Don,

when you say
Quote
Maybe another way that would be nice is say if all of the lwpolylines were already created, could the routiune gather up all of the lwpolylines and assign to each the same information until complete?


do you mean ALL lwpolylines in the drawing our just the ones that were recently created with BPOLY?

V-Man

  • Bull Frog
  • Posts: 343
  • I exist therefore I am! Finally Retired!
Need help with XDATA
« Reply #13 on: April 21, 2005, 08:29:09 AM »
hmm, good question. Well, I guess the best answer would be for the user to possibly select the lwpolylines that he/she wants or also have the option to select all.
AutoCAD 9 - 2023, AutoCADMap 2008 - 2010, Revit 2012 - 2022, Autocad Civil 3D 2023

Jimmy D

  • Guest
Need help with XDATA
« Reply #14 on: April 21, 2005, 08:34:28 AM »
Don,

Just to get it right:

The user generates some LWPOLYLINES.
The user starts the lisp and is prompted "select the LWPOLYLINES or SELECT ALL"?

V-Man

  • Bull Frog
  • Posts: 343
  • I exist therefore I am! Finally Retired!
Need help with XDATA
« Reply #15 on: April 21, 2005, 10:23:45 AM »
Correct. If that is possible.

Say there are 10 lwpolylines. The user intiates the command and is prompted to select 1 or many (all) then, the routine will assign the xdata accordingly to each lwpolyline with the specific information that is gathered from the lisp. The only thing that will be different would be the entity handle in the xdata, all of the rest of the xdata information will be the same.
AutoCAD 9 - 2023, AutoCADMap 2008 - 2010, Revit 2012 - 2022, Autocad Civil 3D 2023

Jimmy D

  • Guest
Need help with XDATA
« Reply #16 on: April 22, 2005, 02:11:10 AM »
Don,

I believe something like this should do it.
Didn't do much testing though, and no error-trapping etc...

Code: [Select]
(defun c:ppp ()
   (setvar "cmdecho" 0)      ;switch off command echo

;;Select one, multiple or all LWPOLYLINE's
(initget 1 "Select All")
(setq Keyw (getkword "\nEnter selection option (Select / All): "))
(cond
((= Keyw "Select")(setq SS (ssget '((0 . "LWPOLYLINE")))))
((= Keyw "All")(setq SS (ssget "X" '((0 . "LWPOLYLINE")))))
)

;check if the application has been registered
   (if (not (tblsearch "APPID" "CP_INFO"))
;if not, register it
             (regapp "CP_INFO"))            

;Get dwgprefix,... once
(setq dwgprefix# (getvar "dwgprefix"))
(setq dir (substr dwgprefix# 20 6))
(setq dwgname (getvar "DWGNAME"))

(setq Count 0)
   ;loop SS-list
  (repeat (sslength SS)
    ;select one entity from list
    (setq e (entget (ssname SS Count)))
     ;if there is no exdata
     (if (not (assoc -3 e))          
     (progn
       ;create new xdata list
       (setq xd (list (list -3 (list "CP_INFO"
                (cons 1000 "CP_TAG|SPACE")
                (cons 1000 (strcat "dde|" dir "|" dwgname "|" (cdr (assoc 5 e)))))
       )))
      ;append it and entmod
      (setq e (append e xd))
      (entmod e)
      (setq Count (+ Count 1))
      ));end if end progn
    );end repeat
(princ)
)


I left out the subroutine (didn't have much use anymore) and I've put
the xdata to append in one line.

I hope this is what you wanted  :D

V-Man

  • Bull Frog
  • Posts: 343
  • I exist therefore I am! Finally Retired!
Need help with XDATA
« Reply #17 on: April 22, 2005, 07:51:14 AM »
That did it. Many thanks. That was exactly what I was trying to accomplish.
AutoCAD 9 - 2023, AutoCADMap 2008 - 2010, Revit 2012 - 2022, Autocad Civil 3D 2023

Jimmy D

  • Guest
Need help with XDATA
« Reply #18 on: April 22, 2005, 08:00:03 AM »
I'm glad that I could help!  :lol:

V-Man

  • Bull Frog
  • Posts: 343
  • I exist therefore I am! Finally Retired!
Need help with XDATA
« Reply #19 on: April 22, 2005, 08:08:43 AM »
I will post the final code once I tweak it a bit.
AutoCAD 9 - 2023, AutoCADMap 2008 - 2010, Revit 2012 - 2022, Autocad Civil 3D 2023

V-Man

  • Bull Frog
  • Posts: 343
  • I exist therefore I am! Finally Retired!
Need help with XDATA
« Reply #20 on: April 22, 2005, 08:36:21 AM »
Ok, as promised here si the final code. I added a few thingies to it and added error functionality.

Code: [Select]

(defun tag_err (msg) ;; error handler
    (tag_exit)
    (if
      (or
        (= msg "Function cancelled")
        (= msg "quit / exit abort")
      )
      (princ)
      (princ (strcat "\nError: msg"))
    );end if
    (princ)
);end tag_err
(defun tag_start () ;; startup function
    (command "_.UNDO" "BEGIN")
    (setq olderr *error*
          *error* tag_err)
    (setq oldecho (getvar "cmdecho"))
    (setvar "cmdecho" 0)
    (princ)
);end tag_start
(defun tag_exit () ;; exit function
    (setvar "cmdecho" oldecho)
    (setq *error* olderr
          olderr nil)
    (command "_.UNDO" "END")
    (princ)
);end tag_exit
(defun c:tag ( / Keyw SS dwgprefix# dir dwgname count e xd )
(tag_start)
   (setvar "cmdecho" 0)      ;switch off command echo
(initget 0 "Select All")
(setq Keyw (getkword "\nEnter selection option (Select / All) <All> : ")) ;;Select one, multiple or all LWPOLYLINE's
   (if (or
         (= Keyw "")
         (null Keyw)
       );end or
     (setq Keyw "All")
     (setq Keyw "Select")
   )
(cond
((= Keyw "Select")(setq SS (ssget '((0 . "LWPOLYLINE")))))
((= Keyw "All")(setq SS (ssget "X" '((0 . "LWPOLYLINE")))))
)
;check if the application has been registered
   (if (not (tblsearch "APPID" "CP_INFO"))
;if not, register it
             (regapp "CP_INFO"))
;Get dwgprefix,... once
(setq dwgprefix# (getvar "dwgprefix"))
(setq dir (substr dwgprefix# 20 6))
(strip_extension (getvar "dwgname"))
(setq dwgname (strip_extension (getvar "dwgname")))
(setq Count 0)
   ;loop SS-list
  (repeat (sslength SS)
    ;select one entity from list
    (setq e (entget (ssname SS Count)))
     ;if there is no exdata
     (if (not (assoc -3 e))
     (progn
       ;create new xdata list
       (setq xd (list (list -3 (list "CP_INFO"
                (cons 1000 "CP_TAG|SPACE")
                (cons 1000 (strcat "dde|" dir "|" dwgname "|" (cdr (assoc 5 e)))))
       )))
      ;append it and entmod
      (setq e (append e xd))
      (entmod e)
      (setq Count (+ Count 1))
      ));end if end progn
    );end repeat
  (tag_exit)
(princ)
)
(defun strip_extension (filename / cnt fname found)
  (setq cnt 1
 fname "")
  (repeat (strlen filename)
    (if (= (substr filename cnt 1) ".")
      (setq found T)
    )
    (if (not found)
      (setq fname (strcat fname (substr filename cnt 1)))
    ) ;end if
    (setq cnt (1+ cnt))
  ) ;end repeat
  (eval fname)
)


Thanks again for the help.
AutoCAD 9 - 2023, AutoCADMap 2008 - 2010, Revit 2012 - 2022, Autocad Civil 3D 2023