Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

How to copy and paste to coordinates and rotation list

jobin.e
Enthusiast

How to copy and paste to coordinates and rotation list

jobin.e
Enthusiast
Enthusiast

Hi,

 

Using the same procedure of pasting a coordinate (X,Y) list into the command line, can we add rotation angle of each instance also into each line so that each block will have a unique rotation value as per the list. 

 

Regards

Jo

0 Likes
Reply
Accepted solutions (2)
4,889 Views
27 Replies
Replies (27)

Moshe-A
Mentor
Mentor

@jobin.e  hi,

 

When you use PASTE (or PASTEBLOCK) command a moment before you specify the coordinate you have the options to Scale \ Rotate. by enter S for scale or R for rotate.

 

Moshe

 

0 Likes

jobin.e
Enthusiast
Enthusiast

I was pasting multiple instances using a coordinate list. So my question was along with the coordinates if there was a command syntax to set rotation of each element separately using a list. 

 

Similar to the -insert command 

 

(command "_-INSERT" "blockname" "-550,1628.1406" 1 1 140 ) 

 

Jo

0 Likes

Moshe-A
Mentor
Mentor

@jobin.e 

 

try this

 

(defun c:cpr ()
 (if (setq ss (ssget))
   (progn
   (command "._copyclip" "_si" "_previous") 
   (command "._pasteclip" "_rotate" 45 pause)
  )
 )
)

 

 

 

0 Likes

jobin.e
Enthusiast
Enthusiast

Hi, 

 

The lisp provided changes the angle by 45 to the previous copy. 

 

I think I was not clear in my explanation of the issue. 

 

i am using the copy command then entering a list of coordinates in the command line

for example from a spreadsheet


481124.241,2761191.709
481135.811,2761188.834
481113.401,2761196.688
481093.631,2761210.003

My question was that if along with each of these coordinate entry if I needed to specify a rotation of that item say 32 degrees for first then 25 degrees for the second and so on (around its specified basepoint) also from the spreadsheet, if there was any way to do this. 

 

0 Likes

Moshe-A
Mentor
Mentor

@jobin.e ,

 

Are you sure you now supplied us with all the info we need to understand this issue? something tells me NO?!

anyhow there is not built-in procedure to deal with this,  you need AutoLISP application.

 

Moshe

 

 

 

 

0 Likes

Moshe-A
Mentor
Mentor

@jobin.e ,

 

here a lisp command CSVIN to insert blocks from excel csv file. an sample of data format:-

; block name  XCoords     YCoords        XScale  YScale  ZScale  angle degrees
N arrow,	481124.241,	2761191.709,	 1.0,	 1.0,	  1.0,	 	32.0
N arrow,	481135.811,	2761188.834,	 1.0,	 1.0,	  1.0,	 	25.0
N arrow,	481113.401,	2761196.688,	 1.0,	 1.0,	  1.0,	 	47.0
N arrow,	481093.631,	2761210.003,	 1.0,	 1.0,	  1.0,	 	18.0

 

the omit the header from file. replace "N arrow" with your blocks name.

each record must have all these fields in this order. 

 

wrap the following in lsp file and load it in autocad

 

(vl-load-com)

;; String to List  -  Lee Mac
;; Separates a string using a given delimiter
;; str - [str] String to process
;; del - [str] Delimiter by which to separate the string
;; Returns: [lst] List of strings
 
(defun LM:str->lst ( str del / pos )
    (if (setq pos (vl-string-search del str))
        (cons (substr str 1 pos) (LM:str->lst (substr str (+ pos 1 (strlen del))) del))
        (list str)
    )
)


(defun c:csvin (/ _str->num _dtr ; local function
                  fdata fname f)

 ; anonymous functions 
 (setq _str->num (lambda (s) (atof (vl-string-trim " " s))))
 (setq _dtr (lambda (s) (* (/ (_str->num s) 360.0) 2 pi)))

 (vla-startUndoMark (vla-get-activedocument (vlax-get-acad-object)))
  
 (cond
  ((not (setq fname (getfiled "Select csv data file" "" "csv" 8))))
  ((not (setq f (open fname "r")))
   (vlr-beep-reaction) 
   (prompt (strcat "\nfail to open " fname))
  )
  ( t
   (while (setq line (read-line f))
    (setq fdata (cons (LM:str->lst line ",") fdata))
   )  
   (setq f (close f))

   (foreach item (reverse fdata)
    (entmake 
     (list
      '(0 . "insert")
       (cons '2 (nth 0 item))
       (cons '10 (list (_str->num (nth 1 item)) (_str->num (nth 2 item))))
       (cons '41 (_str->num (nth 3 item)))
       (cons '42 (_str->num (nth 4 item)))
       (cons '43 (_str->num (nth 5 item)))
       (cons '50 (_dtr (nth 6 item)))
      '(210 0.0 0.0 1.0)      
     ); list
    ); entmake
   ); foreach

  ); case
 ); cond
   
 (vla-endundoMark (vla-get-activedocument (vlax-get-acad-object)))
 (princ)
); csvin

 

 

Kent1Cooper
Consultant
Consultant

@jobin.e wrote:

... along with the coordinates if there was a command syntax to set rotation of each element separately using a list. 

Similar to the -insert command 

(command "_-INSERT" "blockname" "-550,1628.1406" 1 1 140 )


(command "_.pasteclip" "_rotate" {YourRotationFromTheList} {YourCoordinatesFromTheList})

Kent Cooper, AIA

jobin.e
Enthusiast
Enthusiast

are the coordinates in quotes? would it be too much trouble to list a sample of 3 sample coordinate and rotation instances?

0 Likes

Kent1Cooper
Consultant
Consultant

@jobin.e wrote:

are the coordinates in quotes? would it be too much trouble to list a sample of 3 sample coordinate and rotation instances?


What does "the list" in Message 1 refer to?  I assumed you already have "the list," and whatever form it's in, its information could probably be converted appropriately, but we would need to know what the format and/or file type are, preferably with a [small] sample.

Kent Cooper, AIA
0 Likes

jobin.e
Enthusiast
Enthusiast

Here's where i am. 

 

1. I have an excel register of speakers that have their unique ABS codes and coordinates (easting & northing). 

 

Step 1Step 1

2. I am creating these speakers in the model using a multi-view block placed within a block. 

 

Step 2Step 2

3. For this speaker block i have a block attribute definition for ABS Code which will be fed directly from the excel ABS code. 

 

Step 3Step 3

 

4. I have also created a property set for ABS Code in extended data. This property set is directly linked to block attribute of that same block using fields. 

 

Step 4aStep 4a

 

Step 4bStep 4b

 

5. Now if I just insert blocks directly using the coordinates available to me I dont get this linking of block attribute to property set in step 5. So what i am doing is doing the linking for 1 speaker block, then copying to the coordinates in the excel register. This way the linking for each block remains. 

 

6. The reason i am doing this is so i can label this using mtexts and multileaders also linked to fields of the block attribute. These are linked to each blocks individually. 

 

Step 5&6Step 5&6

 

7. Right now as a work around i am saving the block with active links, multileaders into a new block. then inserting this as a set so the rotation of speakers is preserved. 

 

Step 7Step 7

 

8. after which i explode the block and set all the multi leaders and mtexts to zero rotation since they also rotate along with the orientation of the speaker. Now i have 700+ speakers with its unique linking and rotation. But i still have to do one more step to ATT in the Codes again using easting northing as an identifier to get the values updated. 

 

Step 8aStep 8a

 

Step 8bStep 8b

 

If there is any way to do this in a better procedure, I would really appreciate your inputs. If not, i will stick to my current workflow. 

 

PS: I am really sorry to @Moshe-A that I didn't explain the whole situation because it was a lengthy process and he was right in noting that I wasn't giving him the entire picture. Thank you so much for your patience guys. 

 

 

ВeekeeCZ
Consultant
Consultant

I am really impressed what you're able get from scripting. We often see here that people underestimates scripts capabilities while they quite simple to construct using vastly well known simple excel functions. They just grab some of our LISP solution which from they don't understand a word.

 

Anyway this task is quite complex to be scripted. LISP with the use of some public library snippets, eg. HERE Lee's function for managing dynamic block properties, would not be difficult to make. But to make it done, you need to post some of real date - the block itself, portion of the excel data and dwg of examples of desired outcomes.

0 Likes

ВeekeeCZ
Consultant
Consultant
Are the coordinates in quotes? would it be too much trouble to list a sample of 3 sample coordinate and rotation instances....

Assuming the original is inserted to the coords of 0,0.

COPYPASTE Last 0,0
PASTECLIP R 20.5 -550,1628.1406
PASTECLIP R 60.2 -560,1628.1406
0 Likes

Moshe-A
Mentor
Mentor

@jobin.e ,

 

i'm thinking of the way to solve this:-

 

You need a small dynamic block which the speaker can be rotate without been dependent on the mtext. the mtext is aligned right (rotation=0) always. the mleader is pointing to the insertion base point of the block (although this may need some tuning here and there)

 

the ASSETID attribute (or something else?) should be the key (fixed) through the link (csv -> dwg) is maintained.

how do you rotate the speakers? if it is a value you know in advance then add that column to csv file.

 

now you need two lisp commands:

1. CSVIN (see message #7 with some modification it will do the job) to insert those speakers-in with ASSETID + ABSCODE set

 

2 . CSV->DWG for update the drawing due to changes in csv file. changes can be made to ABSCODE, to coordinates, rotation angle. true, you manually need to run this each time the csv is changed (i like controlling updates 😀) whereas FIELDS updates is automatically but linked data should exist inside drawing (not in external file) so for this maybe you will need to add a TABLE to your drawing and use DATAEXTRACTION command?

 

thoughts are halfway to solution 😀

Moshe

 

0 Likes

ChicagoLooper
Mentor
Mentor

I'm looking at you uploaded images and I'm curious to know how you got the Pava blocks into modelspace. Did you insert them manually or does your workflow read the coordinates to place them in their correct position? How you answer this question will determine what direction your work flow should go.

 

1.png

 

In addition to plain, vanilla AutoCAD, what other versions do run? Civil3D, Map3D, Revit? 

Chicagolooper

EESignature

0 Likes

jobin.e
Enthusiast
Enthusiast

@Moshe-A My scripting skills are practically non-existent. All the methods and commands used are ootb plain old data extraction, scheduling, ATTIN ATTOUT copy and paste from excel into the command line. 

 

I had tried the dynamic block rotation angle but I wasn't too fond of having a redundant angle value when there was already a stock rotation angle. 

 

If I can somehow copy a set of objects (the block with the field links, the multileader and the mtext with field links) using the CO command and paste to a list of coordinates along with each rotation value I can by pass the whole nested block workaround I am doing. And this was the purpose of my question. 

0 Likes

jobin.e
Enthusiast
Enthusiast

I'm working on the civil 3d environment. However i have so far only used the vanilla ootb AutoCAD features. 

 

For placement this is what I'm currently doing. 

 

1. I have a drawing with the 2d blocks and all the locations. I copy one of these to a blank drawing and make changes to it inside and add the block attributes and property sets and link the fields. Then add the multi leader and mtext with field links to label. Make a new block with all these elements with the same name as of the block in the original 2d block. 

 

2. Ctrl+C all the remaining 2d blocks from the first drawing and paste into new drawing which instead places the modified block of the same name with all the setup done in point 1 with the original rotation. Then i explode the set and set the rotation of all the multi leaders and mtext to zero using quick select. 

0 Likes

ChicagoLooper
Mentor
Mentor

Wow! That’s a lot of work to ‘move’ your data onto your block. And most of the heavy lifting is performed by you and not AutoCad.

 

It’s also strange that your workflow includes exploding your block and that indicates your workflow isn’t doing exactly what you want so you must use explode command to keep your workflow moving forward. 

 

Since you have Civil 3D, you can leverage its power to read the coordinates to insert the blocks and make it read the rotation value to rotate the them too. The functions in C3D will also store attributes, ABS Code and Asset ID, so you can call them up anytime you need them.

 

If you are willing you can do this entirely in C3D and not get stuck like using OOTB vanilla AutoCad. (TIP: If you have GIS-type software you can speed things up, really speed it up.)

How many blocks do you currently need to insert? Over 20? Over 50?

 

Would it be possible to upload the rotation values for the speaker locations shown in Step 1 image of post #11?

 

Chicagolooper

EESignature

0 Likes

jobin.e
Enthusiast
Enthusiast

 

yes I can dataextract the rotation values from the source file and add it to the excel which has the other tags. My question is will I get the multi leader links to the fields. right now if i change the value in the block attribute, it changes in the property set and the multi leader automatically. A static data import to a label will not suffice unfortunately. 

 

If it does that then great. This would help me a lot. 

 

In the screengrab below, the regen command doesn't show up. once I change the attribute a regen command updates the mtext and extended data. 

 

Screengrab.gif

0 Likes

ChicagoLooper
Mentor
Mentor
  1. How many PAVA blocks do you plan to insert?
  2. What are the rotation values for the speakers in the list shown in your image named STEP 1

Chicagolooper

EESignature

0 Likes