Author Topic: Help, Problems with getfiled  (Read 14445 times)

0 Members and 1 Guest are viewing this topic.

KewlToyZ

  • Guest
Help, Problems with getfiled
« on: May 02, 2006, 12:59:15 PM »
I'm trying to re-write a project drawing set up routine.
I'm running into a bigger problem in trying to Autolisp an Overlay with a Relative Path with variations in filename and setting scale equal to dimscale when applicable.
getfiled is giving me problems because I can't quite get the hang of applying it with all of the variations in path, type, & scale.
Hopefully it's just a matter of how I order the operations.
I just found it is strange that the xattach dialog has all of the features necessary but actaully trying to get to them by lisp, to automate a few key aspects, has proven itself a bit past elusive for me. I feel foolsih in assuming the commands would be available to call from lisp.
Not much feedback from AutoDesk just other users offering some feedback only to find it doesn't work either.
Everything seems to make an attempt at emulating this without actually doing it.

Is there a way to expose the code in xattach or the xref systems of CAD?
Mainly I want to take advantage of what is there rather than write something from scratch.
I figured autolisp was the best way to keep it compatible in a long term.
What I had before was inherited from a predecessor with no documentation.
And it works but only if all of the files (drawing, xref's, & insert's) are in the same directory.
With an MEP organization accross 3 states it isn't viable when browsing folders over the intranet.
Less files per folder is better for bandwidth handling and production.
The only drawback is plotting becomes a bit more labor intensive.

I am not proficient with lisp to this depth so this is likely my worst undoing.
Trying to find a book outlining the features of xref with lisp for relative path handling has proven a bit elusive as well.
The recommendations I had are out of print. Any recommendations would be greatly appreciated!

here is what I have so far:
#1 Legacy that doesn't work on outside folders.
-------------------------------------------------------------------------------------------------------------------------------
Code: [Select]
(defun c:dwgsetup()
;/ ds rfgetbck rfgetbor rfgettit)
  (command "rememberfolders" "1")
  (command "saveas" "2004" "~")
  (c:setscale)
  (setup)
; (c:layerset-a)
  (setq ds (getvar "dimscale"))
  (setq rfgetbck (getfiled "Background to XREF attach" (getvar "dwgprefix") "dwg" 2))
  (setq rfgetbor (getfiled "Borders XREF to insert" (getvar "dwgprefix") "dwg" 2))
  (setq rfgettit (getfiled "Title Info BLOCK to insert" (getvar "dwgprefix") "dwg" 2))
  (princ "\nWorking...")
  (if rfgetbck
    (progn
      (if (vl-string-position (ascii "\\") rfgetbck nil T)
(setq slash (+ (vl-string-position (ascii "\\") rfgetbck nil T) 2))
(setq slash 1))
(setq dot (+ (vl-string-position (ascii ".") rfgetbck nil T) 1))
(setq layName (substr rfgetbck slash (- dot slash)))
(command "layer" "make" layName "c" "8" "" "")
(command "xref" "a" layName "0,0" "1" "" "")
;(command "-xref" "p" layName layName)
(command "layer" "lock" layName "")
    )
  )
;end progn&if
  (if rfgetbor
    (progn
      (if (vl-string-position (ascii "\\") rfgetbor nil T)
(setq slash (+ (vl-string-position (ascii "\\") rfgetbor nil T) 2))
(setq slash 1))
(setq dot (+ (vl-string-position (ascii ".") rfgetbor nil T) 1))
(setq layName (substr rfgetbor slash (- dot slash)))
(command "layer" "make" layName "")
(command "xref" "a" layName "0,0" ds "" "")
(command "-xref" "p" layName layName)
(command "layer" "lock" layName "")
    )
  )
;end progn&if
  (if rfgettit
    (progn
      (if (vl-string-position (ascii "\\") rfgettit nil T)
(setq slash (+ (vl-string-position (ascii "\\") rfgettit nil T) 2))
(setq slash 1))
(setq dot (+ (vl-string-position (ascii ".") rfgettit nil T) 1))
(setq layName (substr rfgettit slash (- dot slash)))
(command "layer" "make" layName "")
(command "attreq" "0")
(command "insert" rfgettit "0,0" ds "" "")
(command "attreq" "1")
    )
  )
;end progn&if
(command "units" "4" "64" "2" "4" "" "")
(command "mirrtext" 0)
(command "chamfer" "d" 0 0)
(command "fillet" "r" 0)
(setvar "fillmode" 1)
(command "visretain" 1)
(command "viewres" "y" 5000)
(command "ucsicon" "off")
(command "pellipse" 1)
(command "zoom" "extents")
(command "view" "save" "all")
(princ "\n ")
;(c:shtsetup) 
(end)
)
;end defun

Where I've ended up so far:
---------------------------------------------------------------------------------
Code: [Select]
(defun c:dsu2()
  ; dsu2 command to invoke beta drawing set up routine
  (command "rememberfolders" "1")
  (command "dimscale" "96")
(command "_.saveas" "" (strcat "<>" (getvar "dwgname")))
  (command "saveas" "2004" "~")
  ;(c:setscale)
  (setup)
  (setq ds (getvar "dimscale"))
  ;;;Pause code to get user input:
  (while (= (logand (getvar "cmdactive") 1) 1)
  (command pause)
  )
  ;;; XREF Back ground file from ZBase.dwg
  (progn
    (alert "\nXREF Overlay the ZBase.dwg Background
   \nSet Reference Type: Overlay
   \nSet Path Type: Relative Path
   \nSpecify On-screen: Uncheck All Boxes
   \nUniform Scale: Check Box"))
(command "layer" "make" "ZBase" "Color" "8" "ZBase" "Set" "ZBase" "")
  (command "xattach")
  ;;;Pause code to get user input:
  (while (= (logand (getvar "cmdactive") 1) 1)
  (command pause)
  )
  ;;; Begin XBorder Overlay Command: can't find the order to set the relative path to simply "..\XREF\" "any.dwg"
  (progn
    (alert "\nXREF Overlay the ZBorder.dwg Titleblock Borders"))
(command "layer" "make" "ZBorder" "Color" "8" "ZBorder" "Set" "ZBorder" "")
  (initdia)
  (command "-xref" "overlay" "scale" ds "0,0,0" "0" "")
  (command "zoom" "extents")
  (command "view" "save" "all")
  ;;; Begin XTitle Insert Command
;    (alert "\nIn the next dialog browse to the ZTitles.dwg Title Text BLOCK for Insert"))
  (progn
(command "layer" "make" "ZTitle" "Color" "8" "ZTitle" "Set" "ZTitle" "")
(command "attreq" "1")
    (setq titleblk (getfiled "ZTitle.dwg Titleblock Text for Insert" (getvar "dwgprefix") "dwg" 8))
    (command "insert" titleblk "Scale" ds pause "");"0,0,0" ds
  ;;;Pause code to get user input: Trying to get the block attributes for text to display for any file chosen?
  (while (= (logand (getvar "cmdactive") 1) 1)
  (command pause)
  )
  )
  (command "zoom" "extents")
  (command "view" "save" "all")
  ;;;Run the Sheet Set up Routine:
 ; (c:shtsetup)
  (command "units" "4" "64" "2" "4" "" "")
  (command "qsave")
  (princ "Drawing Set Up Complete") ; double prints at command line?
  )
;end of file

I'm not looking for a hand out. I just need advice on the proper course and learn how to format this better.
Thanks, Best regards,
Chris


<code tags added - CAB>
« Last Edit: May 02, 2006, 01:06:18 PM by CAB »

KewlToyZ

  • Guest
Re: Help, Problems with getfiled
« Reply #1 on: May 02, 2006, 01:13:14 PM »
oops I'll try to make sure I do that in the future  :ugly:

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Help, Problems with getfiled
« Reply #2 on: May 02, 2006, 01:54:05 PM »
This change will simplify your code somewhat.
I can't tell from your new code what you are trying to accomplish.

Code: [Select]
(defun c:dwgsetup ()
  ;/ ds rfgetbck rfgetbor rfgettit)
  (command "rememberfolders" "1")
  (command "saveas" "2004" "~")
  (c:setscale)
  (setup)
  ; (c:layerset-a)
  (setq ds (getvar "dimscale"))
  (setq rfgetbck (getfiled "Background to XREF attach" (getvar "dwgprefix") "dwg" 2))
  (setq rfgetbor (getfiled "Borders XREF to insert" (getvar "dwgprefix") "dwg" 2))
  (setq rfgettit (getfiled "Title Info BLOCK to insert" (getvar "dwgprefix") "dwg" 2))
  (princ "\nWorking...")

  (if rfgetbck
    (progn
      (setq layname (vl-filename-base rfgetbck))
      (command "layer" "make" layname "c" "8" "" "")
      (command "xref" "a" layname "0,0" "1" "" "")
      ;;(command "-xref" "p" layName layName)
      (command "layer" "lock" layname "")
    )
  )
  ;end progn&if
  (if rfgetbor
    (progn
      (setq layname (vl-filename-base rfgetbor))
      (command "layer" "make" layname "")
      (command "xref" "a" layname "0,0" ds "" "")
      (command "-xref" "p" layname layname)
      (command "layer" "lock" layname "")
    )
  )
  ;end progn&if
  (if rfgettit
    (progn
      (setq layname (vl-filename-base rfgettit))
      (command "layer" "make" layname "")
      (command "attreq" "0")
      (command "insert" rfgettit "0,0" ds "" "")
      (command "attreq" "1")
    )
  )
  ;end progn&if
  (command "units" "4" "64" "2" "4" "" "")
  (command "mirrtext" 0)
  (command "chamfer" "d" 0 0)
  (command "fillet" "r" 0)
  (setvar "fillmode" 1)
  (command "visretain" 1)
  (command "viewres" "y" 5000)
  (command "ucsicon" "off")
  (command "pellipse" 1)
  (command "zoom" "extents")
  (command "view" "save" "all")
  (princ "\n ")
  ;(c:shtsetup) 
  (end)
);end defun
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

KewlToyZ

  • Guest
Re: Help, Problems with getfiled
« Reply #3 on: May 02, 2006, 05:37:52 PM »
This change will simplify your code somewhat.
I can't tell from your new code what you are trying to accomplish.

Thanks CAB, that does make things quite a bit easier for me to follow.
The ascii & slash references were confusing me with their intent.
This was a routine inherited from a predecessor Mike Schmidt in 1999.
Quite advanced with lisp from the work I have found in his legacy.
I've ordered a few books on AutoLISP today to make up for my weaker knowledge.

The new code I made is a bit of a mess from me testing options earlier in the day.
I copied the wrong one from a development directory on this machine I had opened in notepad without proof reading.
 :ugly:

The intent was similar to the file you've cleaned up for me.
The problem with it is it returns;
Working...
*Invalid*
#@$@*!@% &!@*%?

I can't reference files from seperate folders.
All 3 files reside in a folder aptly named XREF.
The file I'm writing to resides in the one named after the discipline "MECH, ELEC, ARCH, PLUM, etc.."
They all share the same parent directory.

The first file is an xref overlay with a relative path (..\XREF\filename.dwg)  insertion point 0,0 | 0 rotation | scaled 1:1
I've only been able to get the overlay with the relative path to work through the xattach dialog.
I really dont want all of these settings manual if I could do it from the getfiled browse and keep them in lisp.
I haven't found the right order to do these steps without getting the same error as the legacy file.

The second xref overlay is the titleblock again with a relative path (..\XREF\filename.dwg)  insertion point 0,0 | 0 rotation | scaled = dimscale
I could not get the relative path working from the command line when I used (initdia) overlay.

The third I'm trying to keep my title block text as block inserts scaled = dimscale with a pause to allow for the files attributes dialog to fill in each text space.

I'll try to digest the changes you gave me.
 :-)




« Last Edit: May 02, 2006, 06:15:10 PM by KewlToyZ »

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Help, Problems with getfiled
« Reply #4 on: May 02, 2006, 07:19:50 PM »
OK, try this version and paste you command history if there is an error.

Code: [Select]
(defun c:dwgsetup (/ usercmd ds rfgetbck rfgetbor rfgettit LayerMake)
  (defun LayerMake(lyrname Color ltype)
  (if (tblsearch "LAYER" lyrname)
    (command "._Layer" "_Thaw" lyrname "_On" lyrname "_UnLock" lyrname "_Set" lyrname "")
    (command "._Layer" "_Make" lyrname "_Color"
             (if (or (null color)(= Color "")) "_White" Color) lyrname
             "LT" (if (or (null ltype)(= ltype "")) "Continuous" ltype) lyrname "")
  )
)
  (setq usercmd (getvar "cmdecho"))
  (setvar "cmdecho" 1); debug - turn cmd echo on

  (command "rememberfolders" "1")
  (command "saveas" "2004" "~")
  (c:setscale)
  (setup)
  ; (c:layerset-a)
  (setq ds (getvar "dimscale"))
  (setq rfgetbck (getfiled "Background to XREF attach" (getvar "dwgprefix") "dwg" 2))
  (setq rfgetbor (getfiled "Borders XREF to insert" (getvar "dwgprefix") "dwg" 2))
  (setq rfgettit (getfiled "Title Info BLOCK to insert" (getvar "dwgprefix") "dwg" 2))
  (princ "\nWorking...")
  ;; =============================================================
  ;;  Debug Code
  (print)
  (print rfgetbck)
  (print rfgetbor)
  (print rfgettit)
  ;; =============================================================

  (if rfgetbck
    (progn
      (setq layname (vl-filename-base rfgetbck))
      (LayerMake layname "8" nil)
      (command "xref" "a" rfgetbck "0,0" "1" "" "")
      ;;(command "-xref" "p" layName layName)
      (command "layer" "lock" layname "")
    )
  )
  ;end progn&if
  (if rfgetbor
    (progn
      (setq layname (vl-filename-base rfgetbor))
      (LayerMake layname "" nil)
      (command "xref" "a" rfgetbor "0,0" ds "" "")
      ;;(command "-xref" "p" layname rfgetbor)
      (command "layer" "lock" layname "")
    )
  )
  ;end progn&if
  (if rfgettit
    (progn
      (setq layname (vl-filename-base rfgettit))
      (LayerMake layname "" nil)
      (command "attreq" "0")
      (command "insert" rfgettit "0,0" ds "" "")
      (command "attreq" "1")
    )
  )
  ;end progn&if

  ;;  debug - remove the next line after testing
  (setvar "CMDECHO" usercmd)

 
  (command "units" "4" "64" "2" "4" "" "")
  (command "mirrtext" 0)
  (command "chamfer" "d" 0 0)
  (command "fillet" "r" 0)
  (setvar "fillmode" 1)
  (command "visretain" 1)
  (command "viewres" "y" 5000)
  (command "ucsicon" "off")
  (command "pellipse" 1)
  (command "zoom" "extents")
  (command "view" "save" "all")
  (princ "\n ")
  ;(c:shtsetup) 
  (end)
  (setvar "CMDECHO" usercmd)
);end defun

[edit - fixed error]
« Last Edit: May 03, 2006, 02:25:36 PM by CAB »
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

KewlToyZ

  • Guest
Re: Help, Problems with getfiled
« Reply #5 on: May 03, 2006, 10:30:59 AM »
Command: dsu4
rememberfolders
Enter new value for REMEMBERFOLDERS <1>: 1
Command: saveas
Current file format: AutoCAD 2004 Drawing
Enter file format [2000(LT2000)/2004/Standards/DXF/Template] <2004>: 2004 Save
drawing as <C:\X Store\Drawing1.dwg>: ~
Command:
Initializing...Initializing VBA System...
Working...
Error: bad argument type: stringp nil
#@$@*!@% &!@*%?

I think the strings error out because of the folder seperation failing to adopt relative paths to the files.
The same way XATTACH would refuse to change the paths to No Path when it can no longer find the file.
This would be so much easier if "relative" was an optional command switch in the "path" from command line.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Help, Problems with getfiled
« Reply #6 on: May 03, 2006, 10:52:28 AM »
Please post the values for rfgetbck,  rfgetbor and rfgettit
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

KewlToyZ

  • Guest
Re: Help, Problems with getfiled
« Reply #7 on: May 03, 2006, 11:08:41 AM »
Please post the values for rfgetbck,  rfgetbor and rfgettit

My apologies this is another set of parochial questions:
How do I place tags in the code to show these values as they activate on the command line?
Where would I place the (setvar "CMDECHO" usercmd) and which call could I need instead of usercmd?
Can I do it using the VLIDE console line to execute the program and have it show the operations clearly?

Wish VLIDE had line #'s lol
I have a few text editors that do this : Object Edit & TextPad
Can they be associated with VLIDE to make line #'s available if it uses notepad just replace it with another exe?

I also wanted to clarify if your request for what values the program has or the locations of the files I am using or if you mean the actual files?

« Last Edit: May 03, 2006, 11:15:52 AM by KewlToyZ »

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Help, Problems with getfiled
« Reply #8 on: May 03, 2006, 11:23:35 AM »
Add this
Code: [Select]
  ;; =============================================================
  ;;  Debug Code
  (print)
  (print rfgetbck)
  (print rfgetbor)
  (print rfgettit)
  ;; =============================================================

After this line
Code: [Select]
  (princ "\nWorking...")
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Help, Problems with getfiled
« Reply #9 on: May 03, 2006, 11:32:12 AM »
Can they be associated with VLIDE to make line #'s available if it uses notepad just replace it with another exe?

In VLIDE you set the variables to WATCH.
Highlight the variable name in the code and press [Ctrl W] to add it to the watch window.
Repeat for the other variables.

Put your cursor in front of the parenthesis of this line (if rfgetbck
Then press [F9] the parentheses should turn red, if not press F9 again.
The code will now stop at that point during execution & you can view the variables in the watch window.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

KewlToyZ

  • Guest
Re: Help, Problems with getfiled
« Reply #10 on: May 03, 2006, 01:54:37 PM »
Took these steps, it didn't break there with the watch on.
Every one says "nil"
Did the "Activate AutoCAD" and ran the routine:

Command: dsu4
rememberfolders
Enter new value for REMEMBERFOLDERS <1>: 1
Command: saveas
Current file format: AutoCAD 2004 Drawing
Enter file format [2000(LT2000)/2004/Standards/DXF/Template] <2004>: 2004 Save
drawing as <C:\X Store\Test Files\T9999\CADD\PLUM\dsu4.dwg>: ~
Command:
Working...
Error: bad argument type: stringp nil
#@$@*!@% &!@*%?

I have a parent folder called CADD
I save the file to one of the child discipline folders: CADD\ELEC
I am importing the files from the child folder: CADD\XREF
The paths aren't working is the only reason I could justify the error.
maybe (setvar xreftype 1)?
Additionally there is a basic requirement for an overlay and relative path the drawing be saved before the relative path works but I figured I took care of that at the beginning unless I need a qsave in each routine?


....missed the code in the other post, disregard.
Thanks for the assistance and patience sir  :angel:
« Last Edit: May 03, 2006, 02:02:48 PM by KewlToyZ »

KewlToyZ

  • Guest
Re: Help, Problems with getfiled
« Reply #11 on: May 03, 2006, 02:04:04 PM »
Command: dsu4
rememberfolders
Enter new value for REMEMBERFOLDERS <1>: 1
Command: saveas
Current file format: AutoCAD 2004 Drawing
Enter file format [2000(LT2000)/2004/Standards/DXF/Template] <2004>: 2004 Save
drawing as <C:\X Store\Test Files\T9999\CADD\PLUM\dsu4.dwg>: ~
Command:
Working...

"C:\\X Store\\Test Files\\T9999\\CADD\\XREF\\ZbaseD.dwg"
"C:\\X Store\\Test Files\\T9999\\CADD\\XREF\\Zborders.dwg"
"C:\\X Store\\Test Files\\T9999\\CADD\\XREF\\Ztitles.dwg"
Error: bad argument type: stringp nil
#@$@*!@% &!@*%?

KewlToyZ

  • Guest
Re: Help, Problems with getfiled
« Reply #12 on: May 03, 2006, 02:21:23 PM »
Tried the options I guessed wrong.
Same issues.
Maybe an (if rfgetbck nil princ "n/path not found?")?
But that would just verify the path doesn't work which I already figured.
I'm wondering if I should build the files all sitting in the main CADD directory then use a routine to parse the xref path like:
"xref" "path" "*\\XREF\\" setstring "..\\XREF\\"
but path doesn't accept ".." from the command line with anything.
Code: [Select]
(defun c:dsu4 (/ usercmd ds rfgetbck rfgetbor rfgettit LayerMake)
  (defun LayerMake(lyrname Color ltype)
  (if (tblsearch "LAYER" lyrnamename)
    (command "._Layer" "_Thaw" lyrname "_On" lyrname "_UnLock" lyrname "_Set" lyrname "")
    (command "._Layer" "_Make" lyrname "_Color"
             (if (or (null color)(= Color "")) "_White" Color) lyrname
             "LT" (if (or (null ltype)(= ltype "")) "Continuous" ltype) lyrname "")
  )
)
  (setq usercmd (getvar "cmdecho"))
  (setvar "cmdecho" 1); debug - turn cmd echo on
  (setvar 'xreftype 1)
  (command "rememberfolders" "1")
  (command "saveas" "2004" "~")
  (c:setscale)
  (setup)
  (setq ds (getvar "dimscale"))
  (setq rfgetbck (getfiled "Background to XREF Overlay" (getvar "dwgprefix") "dwg" 2))
  (setq rfgetbor (getfiled "Titleblock Borders to XREF Overlay" (getvar "dwgprefix") "dwg" 2))
  (setq rfgettit (getfiled "Titleblock Title Info BLOCK to insert" (getvar "dwgprefix") "dwg" 2))
  (princ "\nWorking...")
  ;; =============================================================
  ;;  Debug Code
  (print)
  (print rfgetbck)
  (print rfgetbor)
  (print rfgettit)
  ;; =============================================================

  (if rfgetbck
    (progn
      (setq layname (vl-filename-base rfgetbck))
      (LayerMake layname "8" nil)
      (command "xref" "a" rfgetbck "0,0" "1" "" "")
      ;;(command "-xref" "p" layName layName)
      (command "qsave")
      (command "layer" "lock" layname "")
    )
  )
  ;end progn&if
  (if rfgetbor
    (progn
      (setq layname (vl-filename-base rfgetbor))
      (LayerMake layname "" nil)
      (command "xref" "a" rfgetbor "0,0" ds "" "")
      (command "qsave")
      ;;(command "-xref" "p" layname rfgetbor)
      (command "layer" "lock" layname "")
    )
  )
  ;end progn&if
  (if rfgettit
    (progn
      (setq layname (vl-filename-base rfgettit))
      (LayerMake layname "" nil)
      (command "attreq" "0")
      (command "insert" rfgettit "0,0" ds "" "")
      (command "qsave")
      (command "attreq" "1")
    )
  )
  ;end progn&if

  ;;  debug - remove the next line after testing
  (setvar "CMDECHO" usercmd)

 
  (command "units" "4" "64" "2" "4" "" "")
  (command "mirrtext" 0)
  (command "chamfer" "d" 0 0)
  (command "fillet" "r" 0)
  (setvar "fillmode" 1)
  (command "visretain" 1)
  (command "viewres" "y" 5000)
  (command "ucsicon" "off")
  (command "pellipse" 1)
  (command "zoom" "extents")
  (command "view" "save" "all")
  (princ "\n ")
  ;(c:shtsetup) 
  (end)
  (setvar "CMDECHO" usercmd)
);end defun
« Last Edit: May 03, 2006, 02:29:25 PM by KewlToyZ »

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Help, Problems with getfiled
« Reply #13 on: May 03, 2006, 02:26:49 PM »
I had a typo in the code I added. sorry.
Try this.


Code: [Select]
(defun c:dwgsetup (/ usercmd ds rfgetbck rfgetbor rfgettit LayerMake)
  (defun LayerMake(lyrname Color ltype)
  (if (tblsearch "LAYER" lyrname)
    (command "._Layer" "_Thaw" lyrname "_On" lyrname "_UnLock" lyrname "_Set" lyrname "")
    (command "._Layer" "_Make" lyrname "_Color"
             (if (or (null color)(= Color "")) "_White" Color) lyrname
             "LT" (if (or (null ltype)(= ltype "")) "Continuous" ltype) lyrname "")
  )
)
  (setq usercmd (getvar "cmdecho"))
  (setvar "cmdecho" 1); debug - turn cmd echo on

  (command "rememberfolders" "1")
  (command "saveas" "2004" "~")
  (c:setscale)
  (setup)
  ; (c:layerset-a)
  (setq ds (getvar "dimscale"))
  (setq rfgetbck (getfiled "Background to XREF attach" (getvar "dwgprefix") "dwg" 2))
  (setq rfgetbor (getfiled "Borders XREF to insert" (getvar "dwgprefix") "dwg" 2))
  (setq rfgettit (getfiled "Title Info BLOCK to insert" (getvar "dwgprefix") "dwg" 2))
  (princ "\nWorking...")
  ;; =============================================================
  ;;  Debug Code
  (print)
  (print rfgetbck)
  (print rfgetbor)
  (print rfgettit)
  ;; =============================================================

  (if rfgetbck
    (progn
      (setq layname (vl-filename-base rfgetbck))
      (LayerMake layname "8" nil)
      (command "xref" "a" rfgetbck "0,0" "1" "" "")
      ;;(command "-xref" "p" layName layName)
      (command "layer" "lock" layname "")
    )
  )
  ;end progn&if
  (if rfgetbor
    (progn
      (setq layname (vl-filename-base rfgetbor))
      (LayerMake layname "" nil)
      (command "xref" "a" rfgetbor "0,0" ds "" "")
      ;;(command "-xref" "p" layname rfgetbor)
      (command "layer" "lock" layname "")
    )
  )
  ;end progn&if
  (if rfgettit
    (progn
      (setq layname (vl-filename-base rfgettit))
      (LayerMake layname "" nil)
      (command "attreq" "0")
      (command "insert" rfgettit "0,0" ds "" "")
      (command "attreq" "1")
    )
  )
  ;end progn&if

  ;;  debug - remove the next line after testing
  (setvar "CMDECHO" usercmd)

 
  (command "units" "4" "64" "2" "4" "" "")
  (command "mirrtext" 0)
  (command "chamfer" "d" 0 0)
  (command "fillet" "r" 0)
  (setvar "fillmode" 1)
  (command "visretain" 1)
  (command "viewres" "y" 5000)
  (command "ucsicon" "off")
  (command "pellipse" 1)
  (command "zoom" "extents")
  (command "view" "save" "all")
  (princ "\n ")
  ;(c:shtsetup) 
  (end)
  (setvar "CMDECHO" usercmd)
);end defun
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

KewlToyZ

  • Guest
Re: Help, Problems with getfiled
« Reply #14 on: May 03, 2006, 02:48:23 PM »
 
Code: [Select]
(if (tblsearch "LAYER" lyrnamename)
Still the same lol.
I've been racking myself with this for about 2 weeks which was why I abandoned the getfiled use.

Why I've been wondering is there a way to actually break open the code for the xattach command?
The routines are all there just not available outside the dialog through lisp from what I have seen.

KewlToyZ

  • Guest
Re: Help, Problems with getfiled
« Reply #15 on: May 03, 2006, 03:18:35 PM »
Congrats I think you did solve the directory issue  :lmao:
My own typo caused it to error after correcting yours.

Code: [Select]
(defun c:dsu4 (/ usercmd ds rfgetbck rfgetbor rfgettit LayerMake)
  (defun LayerMake(lyrname Color ltype)
  (if (tblsearch "LAYER" lyrname)
    (command "._Layer" "_Thaw" lyrname "_On" lyrname "_UnLock" lyrname "_Set" lyrname "")
    (command "._Layer" "_Make" lyrname "_Color"
             (if (or (null color)(= Color "")) "_White" Color) lyrname
             "LT" (if (or (null ltype)(= ltype "")) "Continuous" ltype) lyrname "")
  )
)
  (setq usercmd (getvar "cmdecho"))
  (setvar "cmdecho" 1); debug - turn cmd echo on
  (setvar "xreftype" 1); set xref type for overlay
  (command "rememberfolders" "1")
  (command "saveas" "2004" "~")
  (c:setscale)
  (setup)
  ; (c:layerset-a)
  (setq ds (getvar "dimscale"))
  (setq rfgetbck (getfiled "Architects Background to XREF Overlay" (getvar "dwgprefix") "dwg" 2))
  (setq rfgetbor (getfiled "Architects Titleblock Borders to XREF Overlay" (getvar "dwgprefix") "dwg" 2))
  (setq rfgettit (getfiled "Titleblock Tags BLOCK to Insert" (getvar "dwgprefix") "dwg" 2))
  (princ "\nWorking...")
  ;; =============================================================
  ;;  Debug Code
  (print)
  (print rfgetbck)
  (print rfgetbor)
  (print rfgettit)
  ;; =============================================================

  (if rfgetbck
    (progn
      (setq layname (vl-filename-base rfgetbck))
      (LayerMake layname "8" nil)
      (command "xref" "a" rfgetbck "0,0" "1" "" "")
      (command "qsave")
      ;;(command "-xref" "p" layName layName)
      (command "layer" "lock" layname "")
      (print layname)
    )
  )
  ;end progn&if
  (if rfgetbor
    (progn
      (setq layname (vl-filename-base rfgetbor))
      (LayerMake layname "" nil)
      (command "xref" "a" rfgetbor "0,0" ds "" "")
      (command "qsave")
      ;;(command "-xref" "p" layname rfgetbor)
      (command "layer" "lock" layname "")
      (print layname)
    )
  )
  ;end progn&if
  (if rfgettit
    (progn
      (setq layname (vl-filename-base rfgettit))
      (LayerMake layname "" nil)
      (command "attreq" "0")
      (command "insert" rfgettit "0,0" ds "" "")
      (command "attreq" "1")
      (command "qsave")
      (print layname)
    )
  )
  ;end progn&if

  ;;  debug - remove the next line after testing
  (setvar "CMDECHO" usercmd)
 
  (command "units" "4" "64" "2" "4" "" "")
  (command "mirrtext" 0)
  (command "chamfer" "d" 0 0)
  (command "fillet" "r" 0)
  (setvar "fillmode" 1)
  (command "visretain" 1)
  (command "viewres" "y" 5000)
  (command "ucsicon" "off")
  (command "pellipse" 1)
  (command "zoom" "extents")
  (command "view" "save" "all")
  (princ "\n ")
  (c:shtsetup) 
  (end)
  (setvar "CMDECHO" usercmd)
);end defun

Quote
Command: dsu4
rememberfolders
Enter new value for REMEMBERFOLDERS <1>: 1
Command: saveas
Current file format: AutoCAD 2004 Drawing
Enter file format [2000(LT2000)/2004/Standards/DXF/Template] <2004>: 2004 Save
drawing as <C:\X Store\Test Files\T9999\CADD\PLUM\dsu4.dwg>: ~
Command:
Working...

"C:\\X Store\\Test Files\\T9999\\CADD\\XREF\\ZbaseD.dwg"
"C:\\X Store\\Test Files\\T9999\\CADD\\XREF\\Zborders.dwg"
"C:\\X Store\\Test Files\\T9999\\CADD\\XREF\\Ztitles.dwg"

"ZbaseD"

"Zborders"
"Ztitles" units Report formats:      (Examples)

  1.  Scientific      1.55E+01
  2.  Decimal         15.50
  3.  Engineering     1'-3.50"
  4.  Architectural   1'-3 1/2"
  5.  Fractional      15 1/2

With the exception of Engineering and Architectural formats,
these formats can be used with any basic unit of measurement.
For example, Decimal mode is perfect for metric units as well
as decimal English units.

Enter choice, 1 to 5 <4>: 4
Enter denominator of smallest fraction to display
(1, 2, 4, 8, 16, 32, 64, 128, or 256) <64>: 64
Systems of angle measure:      (Examples)

  1.  Decimal degrees           45.0000
  2.  Degrees/minutes/seconds   45d0'0"
  3.  Grads                     50.0000g
  4.  Radians                   0.7854r
  5.  Surveyor's units          N 45d0'0" E

Enter choice, 1 to 5 <1>: 2 Enter number of fractional places for display of
angles (0 to 8) <4>: 4

Direction for angle 0d0'0":
   East    3 o'clock  =  0d0'0"
   North  12 o'clock  =  90d0'0"
   West    9 o'clock  =  180d0'0"
   South   6 o'clock  =  270d0'0"
Enter direction for angle 0d0'0" <0d0'0">:
Measure angles clockwise? [Yes/No] <N>
Command: mirrtext
Enter new value for MIRRTEXT <0>: 0
Command: chamfer
(TRIM mode) Current chamfer Dist1 = 0'-0", Dist2 = 0'-0"
Select first line or [uNdo/Polyline/Distance/Angle/Trim/Method/mUltiple]: d
Specify first chamfer distance <0'-0">: 0 Specify second chamfer distance
<0'-0">: 0
Command: fillet
Current settings: Mode = TRIM, Radius = 0'-0"
Select first object or [uNdo/Polyline/Radius/Trim/mUltiple]: r Specify fillet
radius <0'-0">: 0
Command: visretain
Enter new value for VISRETAIN <1>: 1
Command: viewres
Do you want fast zooms? [Yes/No] <Y>: y
Enter circle zoom percent (1-20000) <5000>: 5000
Command: ucsicon
Enter an option [ON/OFF/All/Noorigin/ORigin/Properties] <OFF>: off
Command: pellipse
Enter new value for PELLIPSE <1>: 1
Command: zoom
Specify corner of window, enter a scale factor (nX or nXP), or
[All/Center/Dynamic/Extents/Previous/Scale/Window/Object] <real time>: extents
Regenerating model.

Command: view Enter an option [?/Categorize/lAyer
state/Orthographic/Delete/Restore/Save/Ucs/Window]: save Enter view name to
save: all
UCSVIEW = 1  UCS will be saved with view
Command:

Initializing...expert
Enter new value for EXPERT <0>: 2
Command: layout
Enter layout option [Copy/Delete/New/Template/Rename/SAveas/Set/?] <set>: t
Enter file name: general/24x36.dwt Enter layout name(s) or [?]: 24x36
Command: layout
Enter layout option [Copy/Delete/New/Template/Rename/SAveas/Set/?] <set>: s
Enter layout to make current <Layout1>: 24x36 Regenerating layout.

Command: layer
Current layer:  "Ztitles"
Enter an option
[?/Make/Set/New/ON/OFF/Color/Ltype/LWeight/Plot/Freeze/Thaw/LOck/Unlock/stAte]:
m
Enter name for new layer (becomes the current layer) <Ztitles>: defpoints Enter
an option
[?/Make/Set/New/ON/OFF/Color/Ltype/LWeight/Plot/Freeze/Thaw/LOck/Unlock/stAte]:
t
Enter name list of layer(s) to thaw: defpoints Enter an option
[?/Make/Set/New/ON/OFF/Color/Ltype/LWeight/Plot/Freeze/Thaw/LOck/Unlock/stAte]:
on
Enter name list of layer(s) to turn on: defpoints Enter an option
[?/Make/Set/New/ON/OFF/Color/Ltype/LWeight/Plot/Freeze/Thaw/LOck/Unlock/stAte]:
Command: mview
Specify corner of viewport or
[ON/OFF/Fit/Shadeplot/Lock/Object/Polygonal/Restore/2/3/4] <Fit>: f
Regenerating model.

Command: mview
Specify corner of viewport or
[ON/OFF/Fit/Shadeplot/Lock/Object/Polygonal/Restore/2/3/4] <Fit>: h Hidden line
removal for plotting [ON/OFF]: off
Select objects:   1 found

Select objects:
Command: mspace
Command: zoom
Specify corner of window, enter a scale factor (nX or nXP), or
[All/Center/Dynamic/Extents/Previous/Scale/Window/Object] <real time>: w
Specify first corner: 0,0 Specify opposite corner: 3456,2304
Command: zoom
Specify corner of window, enter a scale factor (nX or nXP), or
[All/Center/Dynamic/Extents/Previous/Scale/Window/Object] <real time>: 1/96xp
Command: pspace
Command: zoom
Specify corner of window, enter a scale factor (nX or nXP), or
[All/Center/Dynamic/Extents/Previous/Scale/Window/Object] <real time>: e
Command: psetupin Enter file name: general/24x36.dwt Enter user defined page
setup(s) to import or [?]: Plotter01 Full Size
Command: psetupin Enter file name: general/24x36.dwt Enter user defined page
setup(s) to import or [?]: Plotter01 Half Size
Command: psetupin Enter file name: general/24x36.dwt Enter user defined page
setup(s) to import or [?]: Plotter02 Full Size
Command: psetupin Enter file name: general/24x36.dwt Enter user defined page
setup(s) to import or [?]: Plotter02 Half Size
Command: psetupin Enter file name: general/24x36.dwt Enter user defined page
setup(s) to import or [?]: Plotter03 Full Size
Command: psetupin Enter file name: general/24x36.dwt Enter user defined page
setup(s) to import or [?]: Plotter03 Half Size
Command: psetupin Enter file name: general/24x36.dwt Enter user defined page
setup(s) to import or [?]: Acrobat Distiller Full Size
Command: psetupin Enter file name: general/24x36.dwt Enter user defined page
setup(s) to import or [?]: Acrobat Distiller Half Size
Command: psetupin Enter file name: general/24x36.dwt Enter user defined page
setup(s) to import or [?]: eDoc PDF Full Size
Command: psetupin Enter file name: general/24x36.dwt Enter user defined page
setup(s) to import or [?]: eDoc PDF Half Size
Command: psetupin Enter file name: general/24x36.dwt Enter user defined page
setup(s) to import or [?]: Plot to File Full Size
Command: psetupin Enter file name: general/24x36.dwt Enter user defined page
setup(s) to import or [?]: Plot to File Half Size
Command: psetupin Enter file name: general/24x36.dwt Enter user defined page
setup(s) to import or [?]: Old Bond Plotter Full Size
Command: psetupin Enter file name: general/24x36.dwt Enter user defined page
setup(s) to import or [?]: Old Bond Plotter Half Size
Command: psetupin Enter file name: general/24x36.dwt Enter user defined page
setup(s) to import or [?]: Old Vellum Plotter Full Size
Command: psetupin Enter file name: general/24x36.dwt Enter user defined page
setup(s) to import or [?]: Old Vellum Plotter Half Size
Command: expert
Enter new value for EXPERT <2>: 0
Command: model Regenerating model.

Command: layout
Enter layout option [Copy/Delete/New/Template/Rename/SAveas/Set/?] <set>: d
Enter name of layout to delete <24x36>: Layout1 Layout "Layout1" deleted.

Command: layout
Enter layout option [Copy/Delete/New/Template/Rename/SAveas/Set/?] <set>: d
Enter name of layout to delete <24x36>: Layout2 Layout "Layout2" deleted.

Command:
Architectural or Engineering pens (A/<E>):
undo Current settings: Auto = On, Control = All, Combine = Yes
Enter the number of operations to undo or [Auto/Control/BEgin/End/Mark/Back]
<1>: e
Command: undo Current settings: Auto = On, Control = All, Combine = Yes
Enter the number of operations to undo or [Auto/Control/BEgin/End/Mark/Back]
<1>: e
Command:


I'm surprised it came down to the layername being an issue causing the failure.
Now if I can parse the xref paths to relative ..\XREF make them overlay and get the title insert to run its block attributes dialog I have a winner.
Whee more research lol.
Actually you have helped me a great deal. I was chasing the wrong issue it would seem.
« Last Edit: May 03, 2006, 03:49:41 PM by CAB »

KewlToyZ

  • Guest
Re: Help, Problems with getfiled
« Reply #16 on: May 03, 2006, 03:29:25 PM »
overlay switch was easy enough.
I have to look over how to parse a variable path with one common element.

Jeff_M

  • King Gator
  • Posts: 4087
  • C3D user & customizer
Re: Help, Problems with getfiled
« Reply #17 on: May 03, 2006, 03:37:11 PM »
<snip> I was chasing the wrong issue it would seem.
I would venture a guess here and say that 90% of all beginner's attempts at debugging code start and head in the wrong direction......I know, I was once there.

For the relative paths.....could you show us the exact structure of the paths for the drawing & xrefs?

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Help, Problems with getfiled
« Reply #18 on: May 03, 2006, 03:52:22 PM »
Great when it works isn't it. :-)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

KewlToyZ

  • Guest
Re: Help, Problems with getfiled
« Reply #19 on: May 03, 2006, 04:32:27 PM »
<snip> I was chasing the wrong issue it would seem.
I would venture a guess here and say that 90% of all beginner's attempts at debugging code start and head in the wrong direction......I know, I was once there.

For the relative paths.....could you show us the exact structure of the paths for the drawing & xrefs?

Well using a Network drive to generalize it so to speak:
X:\Alphabetical\Project#\CADD\XREF\        contains the xrefs of the project
X:\Alphabetical\Project#\CADD\ARCH\       contains architects files to create xref files
X:\Alphabetical\Project#\CADD\ELEC\        discipline specific drawings
X:\Alphabetical\Project#\CADD\MECH\        discipline specific drawings
X:\Alphabetical\Project#\CADD\PLUM\        discipline specific drawings
X:\Alphabetical\Project#\CADD\TELE\        discipline specific drawings
X:\Alphabetical\Project#\CADD\DEMO\        discipline specific drawings

Mainly if the cadd folder is zipped up all of the xref's will be relative for outside clients.
Trying to help things along with a National CAD Standard so to speak making things lower maintenance in the initial set up.
Also breaking this up for multiple states partner firms to access and browse through the intranet by keeping less files per folder for each browse to refresh on the screen.

KewlToyZ

  • Guest
Re: Help, Problems with getfiled
« Reply #20 on: May 03, 2006, 04:34:26 PM »
Great when it works isn't it. :-)

CAB I have to thank you again.
Can you tell me what it is that gave you the insight?

Jeff_M

  • King Gator
  • Posts: 4087
  • C3D user & customizer
Re: Help, Problems with getfiled
« Reply #21 on: May 03, 2006, 04:43:26 PM »
OK, I think that this is what you are looking for......
Code: [Select]
(setq rel-path (strcat "..\\XREF\\" (vl-filename-base rfgetbck) ".dwg"))

Jeff_M

  • King Gator
  • Posts: 4087
  • C3D user & customizer
Re: Help, Problems with getfiled
« Reply #22 on: May 03, 2006, 05:08:03 PM »
And maybe something like this to force the user to select the Xref files from the XREF folder?
Code: [Select]
(setq prefx (getvar "dwgprefix"))
(setq idx (vl-string-search "CADD" prefx))
(setq baseprefix (strcat (substr prefx 1 (+ 5 idx)) "XREF\\"))

  (setq rfgetbck (getfiled "Background to XREF Overlay" baseprefix "dwg" 2))
  (setq rfgetbor (getfiled "Titleblock Borders to XREF Overlay" baseprefix "dwg" 2))
  (setq rfgettit (getfiled "Titleblock Title Info BLOCK to insert" baseprefix "dwg" 2))

KewlToyZ

  • Guest
Re: Help, Problems with getfiled
« Reply #23 on: May 03, 2006, 05:22:16 PM »
OK, I think that this is what you are looking for......
Code: [Select]
(setq rel-path (strcat "..\\XREF\\" (vl-filename-base rfgetbck) ".dwg"))


You rock! I was reading through strcat to get my format. I was close and about to come back and post but you already had it :-)


KewlToyZ

  • Guest
Re: Help, Problems with getfiled
« Reply #24 on: May 03, 2006, 05:27:25 PM »
And maybe something like this to force the user to select the Xref files from the XREF folder?
Code: [Select]
(setq prefx (getvar "dwgprefix"))
(setq idx (vl-string-search "CADD" prefx))
(setq baseprefix (strcat (substr prefx 1 (+ 5 idx)) "XREF\\"))

  (setq rfgetbck (getfiled "Background to XREF Overlay" baseprefix "dwg" 2))
  (setq rfgetbor (getfiled "Titleblock Borders to XREF Overlay" baseprefix "dwg" 2))
  (setq rfgettit (getfiled "Titleblock Title Info BLOCK to insert" baseprefix "dwg" 2))

Alot to be thankful for here.
Jeff that was a finishing touch it needed.

Make me work a little bit though ok ?  :lmao:

Is it possible to have the attribute fire up a dialog during insert or can I reinitialize those attributes after insertion?

Jeff_M

  • King Gator
  • Posts: 4087
  • C3D user & customizer
Re: Help, Problems with getfiled
« Reply #25 on: May 03, 2006, 05:46:40 PM »
Is it possible to have the attribute fire up a dialog during insert or can I reinitialize those attributes after insertion?
Yes.....
During insert....replace the (command "attreq" 0) with:
(sevar "attreq" 1")
(setvar "attdia" 1)

I'll let you search this site for doing it after the fact...... ;-)

One other note, to keep things from getting to the command line that may just confuse a user, don't use (command) to set Sysvars.....use (setvar) as I did above. This method does not echo to the command line.

KewlToyZ

  • Guest
Re: Help, Problems with getfiled
« Reply #26 on: May 03, 2006, 06:10:38 PM »
Thanks Jeff!
You & CAB have shown me enough in one day to really help my understanding.
I was really feeling beaten up trying to piece it together.
Mostly I figured it was a format and syntax issue with myself when I tried to find information to help me along.
I'll post the finished item when I'm done.

KewlToyZ

  • Guest
Re: Help, Problems with getfiled
« Reply #27 on: May 03, 2006, 07:55:14 PM »
Code: [Select]
;;; Drawing Set Up Routine
;;; Special thanks to CAB & Jeff at www.theswamp.org
;;; http://www.theswamp.org/index.php?action=post;topic=9928.15;num_replies=26

(defun c:dwgsetup(/ usercmd ds rfgetbck rfgetbor rfgettit LayerMake)
  (defun LayerMake(lyrname Color ltype)
  (if (tblsearch "LAYER" lyrname)
    (command "._Layer" "_Thaw" lyrname "_On" lyrname "_UnLock" lyrname "_Set" lyrname "")
    (command "._Layer" "_Make" lyrname "_Color"
             (if (or (null color)(= Color "")) "_White" Color) lyrname
             "LT" (if (or (null ltype)(= ltype "")) "Continuous" ltype) lyrname "")
  )
)
  (setq usercmd (getvar "cmdecho"))
  (setvar "cmdecho" 1); debug - turn cmd echo on
;  (setvar "xreftype" 1); set xref type for overlay ----disabled for 2004 enabled for 2006
  (command "rememberfolders" "1")
  (command "dimscale" "96")
  (command "saveas" "2004" "~")
  (c:setscale)
  (setup)
  (setq ds (getvar "dimscale"))
  (setq prefx (getvar "dwgprefix"))
  (setq idx (vl-string-search "CADD" prefx))
  (setq baseprefix (strcat (substr prefx 1 (+ 5 idx)) "XREF\\"))
  (setq rfgetbck (getfiled "Background to XREF Overlay" baseprefix "dwg" 2))
  (setq rfgetbor (getfiled "Titleblock Borders to XREF Overlay" baseprefix "dwg" 2))
  (setq rfgettit (getfiled "Titleblock Title Info BLOCK to insert" baseprefix "dwg" 2))
  (princ "\nWorking...")
;; =============================================================
;;  Debug Code
  (print)
  (print rfgetbck)
  (print rfgetbor)
  (print rfgettit)
;; =============================================================

  (if rfgetbck
    (progn
      (setq layname (vl-filename-base rfgetbck))
      (setq rel-path (strcat "..\\XREF\\" (vl-filename-base rfgetbck) ".dwg"))
      (LayerMake layname "8" nil)
      (command "xref" "o" rfgetbck "0,0" "1" "" "")
      (command "qsave")
      ;(command "-xref" "p" layName (strcat rel-path refgetbck))
      (command "-xref" "p" layName rel-path)
      (command "layer" "lock" layname "")
      (print layname)
    )
  )
;end progn&if
  (if rfgetbor
    (progn
      (setq layname (vl-filename-base rfgetbor))
      (setq rel-path (strcat "..\\XREF\\" (vl-filename-base rfgetbor) ".dwg"))
      (LayerMake layname "" nil)
      (command "xref" "o" rfgetbor "0,0" ds "" "")
      (command "qsave")
      ;(command "-xref" "p" layname (strcat rel-path refgetbor))
      (command "-xref" "p" layname rel-path)
      (command "layer" "lock" layname "")
      (print layname)
    )
  )
;end progn&if
  (if rfgettit
    (progn
      (setq layname (vl-filename-base rfgettit))
      (LayerMake layname "" nil)
      (setvar "attreq" 1)
      (setvar "attdia" 1)   
      (command "insert" rfgettit "0,0" ds "" "")
      (command "qsave")
      (print layname)
    )
  )
;end progn&if

;;  debug - remove the next line after testing
  (setvar "CMDECHO" usercmd)
 
  (command "units" "4" "64" "2" "4" "" "")
  (command "mirrtext" 0)
  (command "chamfer" "d" 0 0)
  (command "fillet" "r" 0)
  (setvar "fillmode" 1)
  (setvar "visretain" 1)
  (command "viewres" "y" 5000)
  (command "ucsicon" "off")
  (setvar "pellipse" 1)
  (command "zoom" "extents")
  (command "view" "save" "all")
  (princ "\n ")
  (c:shtsetup) 
  (end)
  (setvar "CMDECHO" usercmd)
)
;end defun