Jump to content

Recommended Posts

Posted

Hi All and thanks for being really helpful as always,

 

I am trying to use AutoCAD commands like "_insert" in LISP.

my problem is I don't understand how to control or answer the questions coming afterward:

 

specify insertion point or [basepoint/scale/x/y/z/rotate]

 

Is there any source for giving me information about the syntax of different commands?

 

Cheers

 

Ali

Posted

The syntax for using Command Calls is like the flow of the command being executed. Example:

 

 (defun C:test ()
(setq blkname (getstring "\nWhat is the name of the block you would like to insert?"))
(setq point (getpoint "\nPick insertion point"))
(command "-insert" blkname point 1 1 0) (princ))

 

This asks you the name of the block (you could use any block name in your support path, (you don't need the .dwg extension)), the insertion point then inserts the block at 1 xscale 1 yscale and 0 rotation. the negative infront of insert runs the command at the prompt. I suggest you have a look at the Help files for more information though.

 

I hope that helps.

Posted

Just think how the command runs and that's how you emulate it.

 

eg.

Command: -insert
Enter block name or [?] <A$C71D65DF4>: temp

Units: Unitless   Conversion: 1.00000000
Specify insertion point or [basepoint/Scale/X/Y/Z/Rotate]: [color=Red](I picked a point here)[/color]
Enter X scale factor, specify opposite corner, or [Corner/XYZ] <1>: 2
Enter Y scale factor <use X scale factor>: 2

Specify rotation angle <0>: 45

 

Keep in mind that the following code specifies and assumes existence of a block called "TEMP".

 

In code, using PAUSE to receive point from user:

(command "_.-insert" "temp" PAUSE 2. 2. 45.)

In code, using GetPoint to receive point and then executing insert command.

(defun c:TEst (/ pt) [color=Red]; define function and localize variables[/color]
 (if (setq pt (getpoint "\nSpecify insertion point: ")) [color=Red]; get point from user[/color]
  [color=Red] ;; the IF is so the program will ONLY proceed if the point is valid (not nil)[/color]
   (command "_.-insert" "temp" "_non" pt 2. 2. 45.)[color=Red] ; insert block[/color]
   [color=Red];; I added the "_non" to ignore any running osnaps[/color]
 )
 (princ) ; close quietly
)

In a situation where you just want to emulate a carriage return, use "".

 

Hope this helps.

Posted

Oop, sorry Harrison. I wish it would tell you when another user has posted before you submit. Oh well.

Posted

Thank you very much for your help guys,

 

can you please help me with this:

 

I want to insert "ssw1" in (0,0,0) with scale factor x/y/z/ equal to 1 and rotate 0 and also explode when inserted.

 

(command "_insert" "ssw1" ?????)

 

sorry guys but I confused

 

Cheers

 

Ali

Posted

Did you read through my examples?

 

(command "_.-insert" "temp" PAUSE [color=Red]2.[/color] [color=Lime]2.[/color] [color=Magenta]45.[/color])

X Value

Y Value

Rotation

Posted
Did you read through my examples?

 

(command "_.-insert" "temp" PAUSE [color=Red]2.[/color] [color=Lime]2.[/color] [color=Magenta]45.[/color])

X Value

Y Value

Rotation

 

Yahoooo :shock:

 

great I am so excited!!!

 

mate what is "_." in front of _insert?

 

and I inserted my block by the following code in (1508.1524,182.9885,0) point but I don't understand how?! I want to insert it in (0,0,0). Can you please help me with this.

?!@@#!@##$

I open another file and did the same thing and the block inserted right in to (0,0,0)!!!

But I don't understand how?!

I also attached what I received from AutoCAD.

 

(command "_insert" "ssw1" 0. 1. 1. 0.)

Cheers

 

_insert Enter block name or [?]: ssw1

Units: Millimeters Conversion: 1.0000

Specify insertion point or [basepoint/Scale/X/Y/Z/Rotate]: 0.000000000000000

Enter X scale factor, specify opposite corner, or [Corner/XYZ] :

1.000000000000000 Enter Y scale factor : 1.000000000000000

Specify rotation angle : 0.000000000000000

 

Ali

Posted
Oop, sorry Harrison. I wish it would tell you when another user has posted before you submit. Oh well.

 

Don't even worry about it, i was trying to just see if i could help out for once! Your response was more constructed with examples anyway!

 

By the way my VL has been improving since you helped last!

 

Alan, you should see if you can't help me here though...http://www.cadtutor.net/forum/showthread.php?t=47982

 

Thanks!

Posted

_ is to ignore any language differences (Autocad originally written in English)

. is to ignore any redefining of a command.

 

To insert at 0,0,0, you could a string (command will accept), but the best way is to feed it a list.

 

eg.

(command "_insert" "ssw1" '(0. 0. 0.) 1. 1. 0.) 			 		

 

Examine what happens when you pick a point with the following:

Command: (getpoint)
(-20.7212 22.1642 0.0)

Posted

Alan, you should see if you can't help me here though...http://www.cadtutor.net/forum/showthread.php?t=47982

 

Thanks!

Check the other thread. :wink:

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