Author Topic: Help, Problems with getfiled  (Read 14539 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.