Author Topic: Save DXF Files with Unique Names  (Read 3366 times)

0 Members and 1 Guest are viewing this topic.

ziko30

  • Newt
  • Posts: 51
Save DXF Files with Unique Names
« on: June 11, 2010, 11:27:43 AM »
1) --Somehow,  I need to pass the path and name after the "Dxfout" command. Is this the right way to go about it? What I am getting saved is DxfName.dxf, but i want "Dxfname" to change depending on what i gave as "code" (codes are layer names in the main drawing and each layer will be saved as a separate dxf file after being queried from the main drawing)

Code: [Select]

(setq DxfName (strcat "C:\\Data\\DXF\\"Code".dxf"))
(command "dxfout" DxfName "")
Its part of the script below.
 
Code: [Select]
(defun C:SMQ ( / seam dwg ade_tmpprefval dwg_id Cat1 Cat2 Cat3 Cat4 DxfName)
 
   (setvar "cmddia" 0)
   (setvar "cmdecho" 0)
   (setvar "Filedia" 0)
   (command "-osnap" "end" "")
   (command "mapoptions" "q" "N" "N" "N" "N" "N" "N" "N" "a" "i" "i" "red" "red" "N" "x")

   (setq code (getstring "\nEnter code: "))
 
(setq dwg "C:\\Data\\DFX\\Main_Code.dwg")
       (mapcar 'ade_dwgdeactivate (ade_dslist))
        (setq ade_tmpprefval (ade_prefgetval "ActivateDwgsOnAttach"))
        (ade_prefsetval "ActivateDwgsOnAttach" T)
        (setq dwg_id(ade_dsattach dwg))
        (ade_prefsetval "ActivateDwgsOnAttach" ade_tmpprefval)
         (ade_qryclear)

(setq Cat1 (strcat ""code"_Cat1"))
(setq Cat2 (strcat ""code"_Cat2"))
(setq Cat3 (strcat ""code"_Cat3"))
(setq Cat4 (strcat ""code"_Cat4"))

(command "adequery" "c" "d" "P" "la" Cat1 "x" "E" "d")
(command "adequery" "c" "d" "P" "la" Cat2 "x" "E" "d")
(command "adequery" "c" "d" "P" "la" Cat3 "x" "E" "d")
(command "adequery" "c" "d" "P" "la" Cat4 "x" "E" "d")
(command "-layer" "THAW" "*" "")
 
;============================================
(setq DxfName (strcat "C:\\Data\\DXF\\"code".dxf"))
(command "dxfout" DxfName "")
;============================================

(command "zoom" "extents" )
(command "-layer" "unlock" "*" "")

(mapcar 'ade_dsdetach (ade_dslist))
(command "erase" "all" "")
(command "purge" "all" "" "n")

   (setvar "cmddia"  1)
   (setvar "cmdecho" 1)
   (setvar "Filedia" 1)
    (princ)
)

============== Acad Map 3D 2009================

mjfarrell

  • Seagull
  • Posts: 14444
  • Every Student their own Lesson
Re: Save DXF Files with Unique Names
« Reply #1 on: June 11, 2010, 11:30:50 AM »
uh, just a thought...why not perform a save back set of the querried objects, and save to a NEW dwg that has the desired name, and DXF from there?
Be your Best


Michael Farrell
http://primeservicesglobal.com/

ziko30

  • Newt
  • Posts: 51
Re: Save DXF Files with Unique Names
« Reply #2 on: June 11, 2010, 11:49:05 AM »
uh, just a thought...why not perform a save back set of the querried objects, and save to a NEW dwg that has the desired name, and DXF from there?

I could do that... But I want to open one drawing only once, attach the main drawing, query a relevant layer, save out as dxf file, erase and query  next layer and repeat. The only command I want to run over and over  is starting the script. I have many layers, but I also want to know how to save the dxf file in the  way I am asking in my initial post. ( assuming it can be done) If I missed your point let me know.
============== Acad Map 3D 2009================

ziko30

  • Newt
  • Posts: 51
Re: Save DXF Files with Unique Names
« Reply #3 on: June 13, 2010, 03:40:00 PM »
uh, just a thought...why not perform a save back set of the querried objects, and save to a NEW dwg that has the desired name, and DXF from there?

I could do that... But I want to open one drawing only once, attach the main drawing, query a relevant layer, save out as dxf file, erase and query  next layer and repeat. The only command I want to run over and over  is starting the script. I have many layers, but I also want to know how to save the dxf file in the  way I am asking in my initial post. ( assuming it can be done) If I missed your point let me know.

This works...
Code: [Select]
(command "SAVEAS" "DXF" "VERSION" "2010" "OBJECTS" "ALL" "" "16" (strcat (getvar "dwgprefix") code))
============== Acad Map 3D 2009================