Jump to content

Link selected object data to block attribute by selecting objects


srikanth_0126

Recommended Posts

Posted (edited)

Hi,

This is my first after so many days using this site.

 

my block have multiple attributes for different types of lengths and one(DUCT_ID) attribute for sequence.

 

i want to link objects length to block attribute(its a field)(MICRODUCT) by using TAG(DUCT_ID).

HOW IT WORKS.

command to select the objects

then ask for DUCT_ID.

then link the selected objects to MICRODUCT.

i'm using lee mac length2 field for now. but in this lisp you have to select the block manually. but blocks our drawing usually in different location initially for easy to work.  

 

thanks in advance.

Capture.JPG

Edited by srikanth_0126
Link to comment
Share on other sites

  • 2 weeks later...

Sorry for the delay please try this. 

 

; https://www.cadtutor.net/forum/topic/86153-link-selected-object-data-to-block-attribute-by-selecting-objects/
; select block touching plines and get length of pline
; insert block with field attribute
: By AlanH June 20204


(defun c:blkpl ( / ss x obj ins pt1 pt2 pt3 ss2 obj2 str2)
(prompt "Select blocks touching plines" )
(setq ss (ssget '((0 . "INSERT")(2 . "AAAA"))))
(if (= ss nil)
(progn (alert "You have not selected block AAAA will exit now")(EXit))
)
(setvar 'attreq 0)
(repeat (setq x (sslength ss))
  (setq obj (vlax-ename->vla-object (ssname ss (setq x (- x 1)))))
  (setq ins (vlax-get obj 'Insertionpoint))
  (setq atts (vlax-invoke obj 'Getattributes))
  (setq attstr (vlax-get (nth 0 atts) 'Textstring))
  (setq pt1 (mapcar '+ ins (list -5.0 -5.0 0.0)))
  (setq pt2 (mapcar '+ ins (list 5.0 -5.0 0.0)))
  (setq pt3 (mapcar '+ ins (list 5.0 5.0 0.0)))
  (setq pt4 (mapcar '+ ins (list -5.0 5.0 0.0)))
  (setq pts (list pt1 pt2 pt3 pt4 pt1))
  (setq ss2 (ssget "F" pts '((0 . "LWPOLYLINE"))))
  (setq obj2 (vlax-ename->vla-object (ssname ss2 0)))
  (setq str (strcat "%<\\AcObjProp Object(%<\\_ObjId "
  (itoa (vla-get-Objectid obj2))
  ">%).Length \\f \"%lu6\">%")
  )
  (command "-insert" "duct_callout" "S" 1 (getpoint "\npick a point for block ") 0)
  (setq obj (vlax-ename->vla-object  (entlast)))
  (setq atts (vlax-invoke obj 'Getattributes))
  (vla-put-textstring  (nth 0 atts) attstr)
  (vla-put-textstring  (nth 1 atts) str)
)
(setvar 'attreq 1)
(princ)
)
(c:blkpl)

 

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