Jump to content

Lisp for inserting 4 blocks with 2 points and direction


con

Recommended Posts

Hi

 

Thanks in advance for reading and trying to help.

 

I'ld like to make a lisp (autocad) to insert 4 blocks using the following method.

 

https://image.ibb.co/iynhk6/LISP_OR_DYNBLOCK.png

LISP_OR_DYNBLOCK.png

 

Blue dots are points I will select.

Red dots are the blocks insert point.

 

 

 

It doesn't have to be a working lisp, just some usefull lisp-codes would be nice too. Thanks again!

Link to comment
Share on other sites

I dont have the time to help you with a full code,

 

But at first glace this looks like a combination of

 

(getpoint)

(command "_insert" "blockname" "S" "1" "" "" "")

where the XY could be manipulated with:

 

(setq test (getpoint))
(setq newtest (mapcar '+ test (list 1.000 1.000 0.000) ;change x y z by given mapcar values.

 

and use newtest as insertionpoint for the block

Link to comment
Share on other sites

I've looked into Minsert, but the blocks need be exploded for blockcount.

Also It allows for only one block to be inserted.

 

Thanks for the responces so far!

I'm trying to write something myself but i'm a novice

Link to comment
Share on other sites

To get you started:

(defun C:CADTUTOR ( / )
(initget (+ 1))
(setq inspt (getpoint "\nSelect insertionpoint for first block: "))
(initget (+ 1 2 4))
(setq offpt (+ 0.12 (getreal "\nOffset distance for secondblock: ")))
(if (and (/= inspt nil) (/= offpt nil))
	(progn
		(command "-INSERT" "BlockA" "S" "1" (mapcar '+ inspt (list 0.000	0.000	0.000)) "0")
		(command "-INSERT" "BlockA" "S" "1" (mapcar '+ inspt (list 0.000	offpt	0.000)) "0")
		(command "-INSERT" "BlockB" "S" "1" (mapcar '+ inspt (list 0.025	(/ (- offpt 0.12) 2)	0.000)) "0")
		(command "-INSERT" "BlockB" "S" "1" (mapcar '+ inspt (list [color="red"]0.975[/color]	(/ (- offpt 0.12) 2)	0.000)) "0")
	)
	(progn
		(princ "Missing variables...")
	)
)
(princ)
)

 

The part in RED is 1m -0.025 cm... Assuming your block is 1m long and 12 cm wide?

Link to comment
Share on other sites

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