Announcements
Notice: Upload of PDF documents is currently unavailable across the Community due to an ongoing issue.

Copy Attribute to clipboard

Copy Attribute to clipboard

jason.lEZRWT
Explorer Explorer
2,671 Views
12 Replies
Message 1 of 13

Copy Attribute to clipboard

jason.lEZRWT
Explorer
Explorer

Hi All. First time poster.

 

I'm looking for something I feel should be pretty easy, but just not finding it. I need to get an Attribute value from one block and paste it into multiple different blocks (different TAG).

Currently routine is:

- Double Click Source Attribute

- Ctrl C

- Mouse over to Enhanced Att Editor

- Click OK to close

- Select all destination Blocks

- Find appropriate Att in the Propeties 

- Ctrl V

 

At the very least I'd like to be able to:

- Select tool (or type command),

- Click on any visible Attribute and have its value copied to the clipboard

- Select all destination Blocks

- Find appropriate Att in the Propeties 

- Ctrl V

 

I'm mostly just trying to eliminate the whole Enhanced Att Editor part, but if anyone has any better suggestions, I'm all ears. I have to do this a lot and any eliminated clicks, keys, or mice are helpful.

 

 

 

It would be super awesome to eliminate the Ctrl V at the end but I'm sure that would kick up the complexity a bit. 

0 Likes
Accepted solutions (1)
2,672 Views
12 Replies
Replies (12)
Message 2 of 13

pbejse
Mentor
Mentor

@jason.lEZRWT wrote:

It would be super awesome to eliminate the Ctrl V at the end but I'm sure that would kick up the complexity a bit. 


If the target blocks are on the same drawing, there would be no need to Ctrl C and Ctrl V at all. It couldn't be that hard to write a code that is suited to your requirements. But what do you think is missing here? If we could only see a sample drawing....  🤔

 

A simple code could be like this 

 

(defun c:tf (/ astc)
  	(vl-load-com)
 	(setq astc (vla-get-textstring
    	(vlax-ename->vla-object
      		(car (nentsel "\nSelect Text: "))))
	      
	      )
  (while (setq trgt (vlax-ename->vla-object (car (nentsel "\nText to change: "))))
    	
  	(vlax-put-property trgt 'TEXTSTRING astc)
    		)
  )

 

 

HTH

 

0 Likes
Message 3 of 13

Kent1Cooper
Consultant
Consultant

It doesn't eliminate the Ctrl+V part, but at least you can skip the Attribute-editor middle-man, this way:

 

(cdr (assoc 1 (entget (car (nentsel "\nSelect Attribute to get value from: ")))))

That will put the contents in the command line, whence you can Ctrl+C copy it for pasting in at the Properties palette.  I'm sure there's a way to feed it to the clipboard for you instead of [or in addition to] the command line [so you don't need to do the Ctrl+C part] -- I'll let you Search for that.

EDIT:  For brevity, at least, >this< looks promising as a way to do that.

Kent Cooper, AIA
0 Likes
Message 4 of 13

jason.lEZRWT
Explorer
Explorer

Thank you so much for getting back. Here's the details and a sample drawing.

 

I'm working on Wiring Schematics. The wires need to be associated with the Source and Destination connectors. The connectors have attribute Ref_Des (shown in green). The wires have attributes SOURCE_REFDES and DEST_REFDES. The connector attribute needs to be copied to the wires SOURCE_REFDES or DEST_REFDES respectively. 

 

As noted below, I'm currently copying the connector REF_DES via Enhanced Att Editor, selecting all applicable wires, and pasting the value via the properties window.

0 Likes
Message 5 of 13

jason.lEZRWT
Explorer
Explorer

Current Routine. Didn't note before that there's some ESCs in there too.

0 Likes
Message 6 of 13

ВeekeeCZ
Consultant
Consultant
Accepted solution

Select the wires first, then pick a source and desc. Or just one of them, and RT click for the other....

 

(vl-load-com)

(defun c:WC ( / w s d i e)

  (princ "Select wires, ")
  (setq w (ssget '((0 . "INSERT"))))
  (and (setq s (car (nentsel "\nSource: ")))
       (setq s (cdr (assoc 1 (entget s)))))
  (and (setq d (car (nentsel "\nDestination: ")))
       (setq d (cdr (assoc 1 (entget d)))))

  (if (and w (or s d))
    (repeat (setq i (sslength w))
      (setq e (ssname w (setq i (1- i))))
      (and s (vl-catch-all-apply 'setpropertyvalue (list e "SOURCE_REFDES" s)))
      (and d (vl-catch-all-apply 'setpropertyvalue (list e "DEST_REFDES" d)))))
  (princ)
  )

 

0 Likes
Message 7 of 13

jason.lEZRWT
Explorer
Explorer

Holy Smokes! That's absolutely perfect! Thank you so much!

0 Likes
Message 8 of 13

ВeekeeCZ
Consultant
Consultant

FYI about your original workflow.

Hold CTRL when double-clicking on att to get contextual att editor... a bit faster. 

0 Likes
Message 9 of 13

jason.lEZRWT
Explorer
Explorer

Just learned that trick this morning. It's a good tip. I need to get in the habit of that one. Just incorporated you program. Works like a charm! Saves a ton of time.

0 Likes
Message 10 of 13

Sea-Haven
Mentor
Mentor

Why not do this as 1 line no need for "and",  the description could be more like this.

 

(setq s (cdr (assoc 1 (entget (car (nentsel "\nPick Source Attribute: "))))))

0 Likes
Message 11 of 13

ВeekeeCZ
Consultant
Consultant

@Sea-Haven wrote:

Why not do this as 1 line no need for "and",  the description could be more like this.

 

(setq s (cdr (assoc 1 (entget (car (nentsel "\nPick Source Attribute: "))))))


 

The AND prevents the ENTGET from failing when nothing was selected.

Yes, could be more descriptive but why?! It's a very specific tool for this job only.

0 Likes
Message 12 of 13

Sea-Haven
Mentor
Mentor

I try to always be descriptive for picks after all the next time it gets ran could be months away and user forgot what to do. Also doing paid work I never know who is going to be using it, including the new kid that started yesterday. I had 8 staff and would occasionally get "how do I run it again"

 

Any one also reading code can follow the sequence pretty easy. 

0 Likes
Message 13 of 13

andkal
Collaborator
Collaborator

Maybe you will also find useful the routine I found >here<. It copies the text content between pointed objects.


• www.autolisps.blogspot.com - Productivity plugins for Autocad and Autocad MEP
• Autodesk AppStore
0 Likes