inserting blocks by using values in excel sheet

inserting blocks by using values in excel sheet

ebru_kilinc
Enthusiast Enthusiast
3,301 Views
22 Replies
Message 1 of 23

inserting blocks by using values in excel sheet

ebru_kilinc
Enthusiast
Enthusiast

I am searching a method to insert blocks by using excel sheet which contains coordinate and rotation information. My blocks have rotation, x and y attributes. I would like to insert my blocks with correct coordinate and rotation by using my excel sheet. I managed to insert the blocks with several steps but only with the correct x and y values. I can't rotate the blocks by using the rotation value in the excel sheet. do you have any suggestions/ lisps to do the trick?

0 Likes
Accepted solutions (1)
3,302 Views
22 Replies
Replies (22)
Message 2 of 23

leeminardi
Mentor
Mentor

This thread may be helpful (post #8 for syntax).  Note the use of CHAR(34) to distinguish between a quote " used in Excel from those needed in AutoCAD if block names include spaces.

lee.minardi
0 Likes
Message 3 of 23

ebru_kilinc
Enthusiast
Enthusiast

Thank you for the prompt reply. My drawing is in 2D. Unfortunately I couldn't manage the insert blocks with correct rotation. Most probably I am making a mistake somewhere in the concatenate function. I am attaching the drawing and my excel sheet here. You can find the highlighted rotation values in the excel sheet.

0 Likes
Message 4 of 23

leeminardi
Mentor
Mentor

Your Excel sheet does not inlcude your attempt at writing the concatenate command.  Take a stab at it and if you get stuck post your question here.

 

Start by manually entering the command -insert and note the order of prompts you get and your response.  If your block name does not include space characters the syntax to the Excel concatenate function is much simpler.  Hint, after specifying the cell of the bloack name you need to enter "r" to indicate that the cell listed next will be a rotation value if it is to be referenced from the worksheet.

 

Does the attribute you named "rot" have anything to do with the rotation you want for the block or do you just wish to rotate all blocks by the same amount when inserted into the drawing?  

lee.minardi
Message 5 of 23

ebru_kilinc
Enthusiast
Enthusiast

ROT is the attribute name for  the rotation. The blocks has to be rotated based on those value

0 Likes
Message 6 of 23

leeminardi
Mentor
Mentor

ok then, just reference the rot cell after you specifu "r" in the concatenate command.

lee.minardi
0 Likes
Message 7 of 23

ebru_kilinc
Enthusiast
Enthusiast

Unfortunately, I am not an expert in excel 🙂 You mean like this?

0 Likes
Message 8 of 23

ebru_kilinc
Enthusiast
Enthusiast

Unfortunately, I am not an expert in excel 🙂 You mean like this?

0 Likes
Message 9 of 23

ebru_kilinc
Enthusiast
Enthusiast

that is not working

0 Likes
Message 10 of 23

leeminardi
Mentor
Mentor
Accepted solution

Reading through the link I referenced it should be noted that the AutoCAD variable ATTDIA should be set to 0 (not the default 1) to keep the dialog box for attributes from appearing.  Do this before pasting in the commands from Excel.

 

Here's the syntax for the command that you can fill down to other rows.  I'll admit that it is a bit cumbersome.

 

=CONCATENATE("(command ",CHAR(34),"-insert",CHAR(34)," ",CHAR(34),C2,CHAR(34),CHAR(34),F2,",",G2,CHAR(34)," ",CHAR(34),1,CHAR(34)," ",CHAR(34),1,CHAR(34)," ",CHAR(34),E2,CHAR(34)," ",CHAR(34),D2,CHAR(34)," ",CHAR(34),E2,CHAR(34)," ",CHAR(34),F2,CHAR(34)," ",CHAR(34),G2,CHAR(34),")")

 

 

I've attached an Excel file that uses it.  It adds all 4 attributes.

 

lee.minardi
Message 11 of 23

ebru_kilinc
Enthusiast
Enthusiast

Thank you so much! 

0 Likes
Message 12 of 23

Amriya_Exe
Advocate
Advocate

(command "-insert" "ASM""145534.15,6614889.10" "1" "1" "182" "+APR.BC=TCL015.E0A" "182" "145534.15" "6614889.10")


Can you explain me this like first is block name, coordinates(x,y), ?, ?, rotation, ?, ?, ?



I am looking to create commands with insert block with block property distace1 of my dynamic block.

 

my question link is here

0 Likes
Message 13 of 23

leeminardi
Mentor
Mentor

@Amriya_Exe first set ATTDA to 0 to ensure that the dialog box for entering attrbutes does NOT appear.

Enter the command -insert     The hyphen (-) keeps the initial dialog box from appearing. Note the sequenceo f prompts.  That is,

  • block name
  • insertion point
  • x scale
  • y scale
  • rotation angle
  • attribute values (if there are any.  Note the order of prompts if more than one attribute)

Note that in the Excel concatenate command a quote character " is used to tell Excel to use the text as noted.  Without quotes Excel assumes that a cell is being referenced.

For example, 

B6 means get the value in cell B6

"B6" means output the text B6

Char(34) is used to pass to the LISP statement a quote mark 

 

Looking at the begnning of the Excel statement:

=CONCATENATE("(command ",CHAR(34),"-insert",CHAR(34)," ",CHAR(34),C2,CHAR(34)

that yields:

(command "-insert" "ASM" ...

 

We want to output:

(command 

without quotes that is followed by

"-insert"

with quotes.  The char(34) before and after "-insert" add the needed quote marks for the LISP statement.

The CHAR(34) before and after C2 insures that the cell name found in cell C2 will have quotes before and after.  Using a LISP statement also helps to insure the ability to deal with block names that may have space characters.

 

lee.minardi
0 Likes
Message 14 of 23

Amriya_Exe
Advocate
Advocate

In my case I want to insert block name "5mslab" On different coordinates. Rotation 102 and in dynamic block properties options distance 1 should change from excel like 4.890

0 Likes
Message 15 of 23

leeminardi
Mentor
Mentor

If you are asking for help please clearly state your question and  attached a sample AutoCAD file with the block and the Excel file with a few rows of sample data.

lee.minardi
0 Likes
Message 16 of 23

Amriya_Exe
Advocate
Advocate
0 Likes
Message 17 of 23

leeminardi
Mentor
Mentor

@Amriya_Exe Sorry, I cannot help you with this.  

lee.minardi
0 Likes
Message 18 of 23

Amriya_Exe
Advocate
Advocate

yha its seems to like not possible.

0 Likes
Message 19 of 23

ВeekeeCZ
Consultant
Consultant

@Amriya_Exe 

 

This is what you need to create in Excel. That needs to be pasted into the command-line (with F3 OFF). It's called a script. And anyone who can read and follow commands in a command-line can do it.

10 mins job.

 

 

-insert myblock
scale 0.001 rotate 102.476 291193.147055,2314274.47573 (setpropertyvalue (entlast) "AcDbDynBlockPropertyDistance1" 4.857)
-insert myblock
scale 0.001 rotate 102.476 291192.083785,2314279.281515 (setpropertyvalue (entlast) "AcDbDynBlockPropertyDistance1" 4.987)
-insert myblock
scale 0.001 rotate 102.476 291191.006475,2314284.150765 (setpropertyvalue (entlast) "AcDbDynBlockPropertyDistance1" 4.987)

 

 

eekeeCZ_0-1705094534122.png

0 Likes
Message 20 of 23

Amriya_Exe
Advocate
Advocate

I Tried to add this block using your method but its not getting aliened with blue line and dimension not getting changed as per the lengths.

Please check below images.

tastnhsrcl_0-1705386393217.png

 

tastnhsrcl_1-1705386502467.png

 

0 Likes