Announcements

Starting in December, we will archive content from the community that is 10 years and older. This FAQ provides more information.

Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Copy Attribute to clipboard

12 REPLIES 12
SOLVED
Reply
Message 1 of 13
jason.lEZRWT
885 Views, 12 Replies

Copy Attribute to clipboard

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. 

12 REPLIES 12
Message 2 of 13
pbejse
in reply to: jason.lEZRWT


@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

 

Message 3 of 13
Kent1Cooper
in reply to: jason.lEZRWT

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
Message 4 of 13
jason.lEZRWT
in reply to: pbejse

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.

Message 5 of 13
jason.lEZRWT
in reply to: jason.lEZRWT

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

Message 6 of 13
ВeekeeCZ
in reply to: jason.lEZRWT

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

 

Message 7 of 13
jason.lEZRWT
in reply to: ВeekeeCZ

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

Message 8 of 13
ВeekeeCZ
in reply to: jason.lEZRWT

FYI about your original workflow.

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

Message 9 of 13
jason.lEZRWT
in reply to: ВeekeeCZ

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.

Message 10 of 13
Sea-Haven
in reply to: ВeekeeCZ

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: "))))))

Message 11 of 13
ВeekeeCZ
in reply to: Sea-Haven


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

Message 12 of 13
Sea-Haven
in reply to: ВeekeeCZ

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. 

Message 13 of 13
andkal
in reply to: jason.lEZRWT

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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report