Jump to content

Modify a BLOCK definition via lisp


Suha

Recommended Posts

Hello Guys,

 

Say, I have created a block with a single circle entity in it:

(entmake '((0 . "BLOCK") (2 . "myBlock")))
(entmake '((0 . "CIRCLE") (10 0 0 0) (40 . 5)))
(entmake '((0 . "ENDBLK")))

 

Now, I want to modify "myBlock" adding a line entity to this block definiton using pure AutoLisp. So that myBlock will contain a circle and a line at the end.

 

Any advice?

Link to comment
Share on other sites

You can go right back to simplest but least efficient methods if you want

 

for example

(command "bedit" -blockname-)
  (entmake '((0 . "LINE") (10 0 0 0)(11 10 10 0) ))
(command "bsave")
(command "bclose")

 

Quicker than doing it manually.....

 

Though you could just make the line as a part of the block?

 

(entmake '((0 . "BLOCK") (2 . "myBlock")))
  (entmake '((0 . "CIRCLE") (10 0 0 0) (40 . 5)))
  (entmake '((0 . "LINE") (10 0 0 0)(11 10 10 0) ))
(entmake '((0 . "ENDBLK")))

 

Link to comment
Share on other sites

Thanks for the answer Steven P, but my question is to modify by adding /removing the entiti(es).

 

I came up with a solution like this:

(defun c:MakeBlock ()
	(entmake '((0 . "BLOCK") (2 . "myBlock")))
	(entmake '((0 . "CIRCLE") (10 0 0 0) (40 . 5) (-3 ("AD_INSIDE" (1070 . 0)))))
	(entmake '((0 . "ENDBLK")))
)

(defun c:AddLineToBlock()
	(setq head (tblobjname "BLOCK" "myBlock"))
	(entmake (entget head))
	(setq circle (entnext head))
	(entmake (entget circle '("*")))

	(entmake '((0 . "LINE") (10 0 0 0) (11 15 15 0)))
	(entmake '((0 . "ENDBLK")))
	
	(command "_REGEN")
)

 

This achieves the solution I seek, but I expected to use (entmod (entget head)).

 

Is this the regular way or is there better way.

 

 

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