Jump to content

Recommended Posts

Posted

I am stuck on the syntax to write a block without user input.

On executing the lisp, I want it to get a selection set from a variable and then write it to a new block without asking the user for input. The basepoint can be "0,0,0" and the file path is a pre-set path.

 

The general command I'm trying to use goes like this (I know it's wrong, but I don't know where to go from here)

(command "-wblock" "C:\\Users\\DefaultUser\\Desktop\\ScriptTest\\Blocktest1.dxf" "0,0,0")

 

I've searched LISP routines all over the place but can't find one that does this. I'm mostly looking for examples that contain a similar line of code.

Posted

1) I don't think that you can WBLOCK to a dxf format.

 

 

2) To export as a new block try :

 

(command "_.WBLOCK" file_name "" '(0 0 0) 'pickset "")

If you need to retain the entities

(command "_.OOPS")

 

-David

Posted

I'm having trouble making that work. I tried testing it out in a new file in VLIDE. The console history is:

 

3 found

_.WBLOCK Enter name of output file:

C:\Users\DefaultUser\Desktop\ScriptTest\\Blocktest1.dwg

Enter name of existing block or

[= (block=output file)/* (whole drawing)] : Specify

insertion base point:

Select objects: ; error: bad argument value: AutoCAD command: PICKSET

 

here's what I have so far. Is there something I'm doing wrong?

 

(defun c:testingwb ()

(setq pickset (ssget))
(setq file_name "C:\\Users\\DefaultUser\\Desktop\\ScriptTest\\Blocktest1.dwg")
(command "_.WBLOCK" file_name "" '(0 0 0) 'pickset "")
(command "_.OOPS")
)

 

As a side note, I'm in love with the command:

(command "_.OOPS")

It's great fun.

Posted (edited)

Because you used (setq pickset (ssget)) you do not use the single ' with any references to the variable

 

(set 'picksert ...) vs (setq pickset ...) vs (set (quote pickset...)) vs (set (read "PICKSET") ....)

 

HTH -David

 

Oh WOW That was my BAD in post #2 Sorry ! That will teach me not to test snippets of code !

Edited by David Bethel
Posted

The following works for me in 2014.

The second function will let you export a selection set to DXF.

 


(defun c:testingwb ()
 (setq pickset (ssget))
 (setq file_name "C:\\temp\\Blocktest1.dwg")
 (command "_.WBLOCK" file_name "" (list 0.0 0.0 0.0) pickset "")
 (command "_.OOPS")
)

(defun c:dxfobj ( / pickset filename)
 (setq pickset (ssget))
 (setq file_name "C:\\temp\\Blocktest1.dxf")
 (vl-cmdf "_.dxfout" file_name "_O" pickset "" "16")
)

Posted

Greatness has been beheld on this day. Thank you very much, both of you! I am one step closer to sanity.

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...