Jump to content

LISP to read text label as attribute in properties


Jakub

Recommended Posts

Hi,

 

Does exist a lisp that read a text label of point and paste it as attribute?

 

For example:

 

I have a point in CAD that has a text label describing Z coordinate. I need a lisp that read this height and paste into "Z" row in geometry. Then it transforms point from 2D to 3D.

 

Where can I find this type of lisp?

 

Thank you for helping me in advance.

Link to comment
Share on other sites

try this :-

 

For Text :-

(defun c:test (/ a b c d i)
 (if (setq a (ssget '((0 . "text"))))
   (repeat (setq i (sslength a))
     (setq b (entget (ssname a (setq i (1- i)))))
     (setq c (cdr (assoc 10 b)))
     (setq d (subst (atof (cdr (assoc 1 b))) (caddr c) c))
     (entmod (subst (cons 10 d) (assoc 10 b) b))
   )
 )
 (princ)
)

 

 

For Block.... Change the Attribute Tag "A" as per your block tag :-

(defun c:test (/ a b c d i)
 (if (setq a (ssget '((0 . "insert"))))
   (repeat (setq i (sslength a))
     (setq b (vlax-ename->vla-object (ssname a (setq i (1- i)))))
     (setq c (vlax-get b 'InsertionPoint))
     (setq d (vl-some '(lambda	(x)
		  (if (eq (vla-get-tagstring x) "A") ; Change tag here
		    (atof (vla-get-textstring x))
		  )
		)
	       (vlax-invoke b 'GetAttributes)
      )
     )
     (vla-put-insertionpoint
b
(vlax-3d-point (subst d (caddr c) c))
     )
   )
 )
 (princ)
) 

Edited by satishrajdev
Link to comment
Share on other sites

@Jakub - As far as I see in the properties palette, it says that you have nothing selected ... so with that in mind AutoCAD shows you the elevation of the cursor which in 2D view the default elevation of the cursor (or crosshairs whichever you prefer) will always be 0. In order for us to be able to offer you any help you must upload a sample file so we can see exactly what you are dealing with.

@satishrajdev - I think that Jakub wants to elevate the block that represents the point and not only the text that is attached to it! Nice code btw.

 

Best regards,

CAD_89

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