Jump to content

How can I wblock a drawing and save it to the current directory?


Recommended Posts

Posted

I'm new here and to autocad lisp as well so be patient with me.

Here is my problem. I have a mechanical drawing which is being xref by the electrical department. My file is too big and when they open their files it takes a full minute and they always complain about it (I guess you already know if your on the mechanical side). So we decided to wblock only the the equipment that they need to see and save it on the same directory on where my mechanical drawing is and save it Mech-Elec.dwg. Its a pain doing this every time that I close my drawing.

 

 

(defun c:ewblock (/)

 

(command "clayer" "M-Floor")

(command "-layer" "freeze" "~*|*" "")

(COMMAND "-LAYER" "THAW" "M-Floor" "")

(COMMAND "-LAYER" "THAW" "M-Ceiling" "")

(COMMAND "-LAYER" "THAW" "M-Wall" "")

(COMMAND "-LAYER" "THAW" "M-ROOF" "")

(COMMAND "-LAYER" "THAW" "M-Tags" "")

(COMMAND "-LAYER" "THAW" "M-Thermostat" "")

(COMMAND "-LAYER" "THAW""M-Panel" "")

(COMMAND "-LAYER" "THAW" "M-Ex-Floor" "")

(COMMAND "-LAYER" "THAW" "M-Ex-Ceiling" "")

(COMMAND "-LAYER" "THAW" "M-EX-Wall" "")

(COMMAND "-LAYER" "THAW" "M-EX-ROOF" "")

(COMMAND "-LAYER" "THAW" "M-EX-Thermostat" "")

(COMMAND "-LAYER" "THAW""M-EX-Panel" "")

 

(COMMAND "-WBLOCK")

 

-- this is where I'm stuck. I want to automatically save it as Mech-Elec.dwg and on the same folder as my working drawing and use 0,0 as my base point.

 

Please need help....

Posted

Just watch the command line and put the answers in your program you can retrieve current directory etc and add a dwg name as a lisp variable

 

also run it with filedia = 0

 

I think if you answer the dwg name with no path it will save it into the current directory

Posted

the "-" in the -wblock already suppresses the dialog box.

 

The output file is always saved on the last folder which I open and not on my working drawing directory. If I open my working drawing then open a plumbing drawing on the plumbing folder. Then run the code, it will save it under the Plumbing directory. My files were all over the file server.

Posted

You can get the file name by

(SETQ DWG (GETVAR "DWGNAME"))

(SETQ PRE (GETVAR "DWGPREFIX"))

 

You can get what you want by an SSGET call

(setq stuff (ssget))

 

Then you will need to WBLOCK

 

Hope this helps

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...