Jump to content

how to transfer attributes from one block to another.


Recommended Posts

Posted

Please help!

 

I need a routine that will do the following...

1) Click on a block. The block has 2 TAGs.

TAG 1: NODE_ID

TAG 2: AMP_ID

2) Then I want to click on another clock that has 1 TAG.

Tag: SIG_FROM

 

The "SIG_FROM" attribute needs to have a dash between the source TAGs "NOD_ID" & "AMP_ID".

 

Example:

1st block (Source)

TAG 1: NODE_ID = 1234

TAG 2: AMP_ID = 1A2B

2nd block (Destination)

Tag: SIG_FROM = 1234-1A2B (No spaces on either side of dash)

 

Thanks in advance for any help you can give me.

Posted

Sorry about the Title.

 

The code from the link you provided works great except it takes 2 attributes from the first block and updates 2 attributes in the second block.

What I need is 2 attributes from the first block to be combined with a dash in between and update 1 attribute in the second block.

 

Sorry for the confusion.

Posted

I'm sure you have requested something like this before in which the two attributes are strung together to form the input for the third...

Posted

But, if you really can't work it out...

 

Do you want the destination block to be a multiple selection or maybe an automatic update?

Posted

Anyhow... gives me a bit of practice I suppose:

 

 

(defun c:cabltv (/ blk aEnt aEntLst nID aID nAt eLst dEnt dEntLst)
 (if (setq blk (ssget "_:S" (list (cons 0 "INSERT") (cons 66 1)
   (if (getvar "CTAB")(cons 410 (getvar "CTAB"))
      (cons 67 (- 1 (getvar "TILEMODE")))))))
   (progn
     (setq aEnt (entnext (ssname blk 0)))
     (while (not (eq "SEQEND" (cdadr (setq aEntLst (entget aEnt)))))
   (cond ((eq "NODE_ID" (cdr (assoc 2 aEntLst)))
          (setq nID (cdr (assoc 1 aEntLst))))
         ((eq "AMP_ID" (cdr (assoc 2 aEntLst)))
          (setq aID (cdr (assoc 1 aEntLst)))))
   (setq aEnt (entnext aEnt)))
     (setq nAt (strcat nID (chr 45) aID))
     (if (setq ss (ssget (list (cons 0 "INSERT") (cons 66 1)
       (if (getvar "CTAB")(cons 410 (getvar "CTAB"))
         (cons 67 (- 1 (getvar "TILEMODE")))))))
   (progn
     (setq eLst (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))))
     (foreach e eLst
       (setq dEnt (entnext e))
       (while (not (eq "SEQEND" (cdadr (setq dEntLst (entget dEnt)))))
         (if (eq "SIG_FROM" (cdr (assoc 2 dEntLst)))
       (entmod (subst (cons 1 nAt) (assoc 1 dEntLst) dEntLst)))
         (setq dEnt (entnext dEnt)))))
   (princ "\n<!> No Destination Blocks Selected <!>")))
   (princ "\n<!> No Attributed Block Selected <!>"))
 (vl-cmdf "_regenall")
 (princ))
     

Posted

Lee,

As usual it works like a charm!

You may have given me the code (or similar code) before. I have been so enveloped with this project I lost track a little as to what I had and had not completed on my list of things to do. It seemed familiar to me too.

I think this is the last thing on my list that needs to be completed.

 

Thanks for all of your help! You have been of invaluable help to me.

Posted

Thank you for your kind words cabltv - they are much appreciated.

 

Glad it can save you some time in the long run :)

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