Jump to content

linked coordinate


mohammadreza

Recommended Posts

hello guys
i have a lisp that is count few blocks and put in a specific coordinates in a frame (rectangle).
but if i move that frame, lisp doesnt work correctly (because that coordinates doent update)
actually i searched too much and i found need to use ''entmakex'' function , but need some help.
is this below code wrong? why?

(defun c:bb ()
  (setq	block_obj  (car (entsel "Select the block: "))
	block_name (cadr (assoc 2 (entget block_obj))) ; Retrieve the block name
	text_ent   (car (entsel "Select the text: "))
  )
  (entmakex
    (list '(0 . "ASSOC")
	  (cons 2 (cons block_name text_ent))	       ; Associate the block and text entities
	  (cons	10
		(cons block_name (cadr (assoc 10 (entget block_obj))))
	  )
	  (cons	11
		(cons block_name (cadr (assoc 10 (entget block_obj))))
	  )
	  (cons	12
		(cons block_name (cadr (assoc 10 (entget block_obj))))
	  )
    )
  )
  (command "regen")
  (princ)
)

 

Link to comment
Share on other sites

What entity is ASSOC?

 

This line :

block_name (cadr (assoc 2 (entget block_obj))) ; Retrieve the block name

 

Should be :

block_name (cdr (assoc 2 (entget block_obj))) ; Retrieve the block name

Link to comment
Share on other sites

Posted (edited)
15 minutes ago, marko_ribar said:

What entity is ASSOC?

 

This line :

block_name (cadr (assoc 2 (entget block_obj))) ; Retrieve the block name

 

Should be :

block_name (cdr (assoc 2 (entget block_obj))) ; Retrieve the block name

(my block name is rect ) ,i still get error:
Command: BB
Select the block: Select the text:
error: bad DXF group: (2 "rect" . <Entity name: 15af94c8>)
Cannot invoke (command) from *error* without prior call to (*push-error-using-command*).
Converting (command) calls to (command-s) is recommended.

Edited by mohammadreza
Link to comment
Share on other sites

Is this what you are trying to do? Have a block with a field that updates as you move the block?

The block can be a simple rectangle with a point and attribute - the point doesn't have to lie on the rectangle perimeter to allow the text / rectangle to be offset.

 

To entmake or entmakex the field you create an mtext object with the text string being the field definition - which you might get from following this link: https://www.autodesk.com/support/technical/article/caas/sfdcarticles/sfdcarticles/How-to-add-x-y-coordinates-to-block-attribute-in-AutoCAD.html#:~:text=Create a block with x,y coordinates as

  • Agree 1
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...