Block That Requires User Input

Block That Requires User Input

patrickmahoney21
Contributor Contributor
1,195 Views
8 Replies
Message 1 of 9

Block That Requires User Input

patrickmahoney21
Contributor
Contributor

I am creating a cui file that calls out dwgs for blocks. I am creating a ceiling diffures (i.e. a rectrangle with an x through it) and I need to know how to make the block so when the user clicks on the button it asks the user to specify the x distance and y distance of the rectangle. For example if I want to place a 12X24 Ceiling return diffuser, when I click the button I want the pormpt to ask the user to specify the X-distance of 12" and the Y-distance of 24"

0 Likes
Accepted solutions (1)
1,196 Views
8 Replies
Replies (8)
Message 2 of 9

j.palmeL29YX
Mentor
Mentor

Are you looking for somethin like this?

Or this?

Or, which workflow do you prefer?

 

Jürgen Palme
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature

0 Likes
Message 3 of 9

patrickmahoney21
Contributor
Contributor
Like the first link you posted but I am using tool bar with cui file not a tool pallet.
0 Likes
Message 4 of 9

j.palmeL29YX
Mentor
Mentor

Ok. The "secret behind the stage" is a small LISP. Attached a rough draft (quick and dirty) to show the principle.

You can run this LISP from wherever you want. (Of course it must be loaded before). The Tool Palette is only an example.

 

 

Jürgen Palme
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature

0 Likes
Message 5 of 9

patrickmahoney21
Contributor
Contributor

Thank you

0 Likes
Message 6 of 9

patrickmahoney21
Contributor
Contributor

Where do I load the LISP File? In options?

0 Likes
Message 7 of 9

j.palmeL29YX
Mentor
Mentor

@patrickmahoney21 wrote:

Where do I load the LISP File?


- In the command line you can type

Command: (load "YourLispFile.lsp")

- You can use the APPLOAD command. If you always need the LISP, drag the LISP-file into the StartUp Suite.

- You can put the (load ...) command(s) (as mentioned above) in an acad.lsp or acaddoc.lsp


For further informations I'd suggest to ask (or search before ) in the LISP Forum (e.g. here).

 

Jürgen Palme
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature

0 Likes
Message 8 of 9

patrickmahoney21
Contributor
Contributor

So if my block dwg name is rect. here is my lisp I loaded

 

(defun c:rect.dwg (/)
(load rect.dwg)
(Setq X_Dist (Getreal "\nX-Distance: ")
Y_Dist (Getreal "\nY-Distance: ")
P0 (Getpoint "\nInsertpoint: ")
P1 (list (+ (car P0) X_Dist) (cadr P0))
P2 (list (car P1) (+ (cadr P1) Y_Dist))
P3 (list (car P0) (+ (cadr P0) Y_Dist))
)
(command "_rectang" P0 P2)
(command "_line" P0 P2 "")
(command "_line" P1 P3 "")
)

 

And in the cui macro I wrote 

^C^C(load;"TEMP.LSP") to load the lisp when I click the button but it does not work?

0 Likes
Message 9 of 9

j.palmeL29YX
Mentor
Mentor
Accepted solution

@patrickmahoney21 wrote:

So if my block dwg name is rect. here is my lisp I loaded

 

(defun c:rect.dwg (/)
(load rect.dwg)

...


 

No no. It can't work this way.

Obviously you're not familiar with LISP.

Therefore some explanations:

- With (defun c:MyCommand ... ) you define a new command which you can type at the AutoCAD command prompt (or any other way). It never can include a dot (as in your example "rect.dwg".) .

- The LISP command (load ...) loads a LISP file, not an AutoCAD dwg.


I'd suggest this way (as one of any possibilities):

- Create a LISP file as shown here again (I did some small refinements). It is named is diffusor.lsp. Save it anywhere in your suppor path. This LISP defines a new command "xrec".

- Now you can use the following macro (first it loads the LISP file, then it starts the xrec command):

^C^C(load "diffusor");xrec;


BTW: This has nothing to do with blocks. Tis only draws the needed geometry (a rectang and two lines) with the distances you have typed.

 

Jürgen Palme
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature

0 Likes