Import atributos Excel to autocad

Import atributos Excel to autocad

Dambrowski
Contributor Contributor
4,451 Views
25 Replies
Message 1 of 26

Import atributos Excel to autocad

Dambrowski
Contributor
Contributor

I'm looking for a lisp or some solution... import attributes from Excel that can import blocks and give a size and name to each block and coordinates Thanks

0 Likes
Accepted solutions (1)
4,452 Views
25 Replies
Replies (25)
Message 2 of 26

rl_jackson
Mentor
Mentor

You're on the C3D forum so assuming you're using C3D which is built on to of Autocad, the functionality is part of the software look at the ribbon and select points create creation tools. Then you'll use the import icon to import the points based on your format. As far as the blocks you would need to set up description keys and/or point labels to achieve the rest. Perhaps if we could see what you have, we could point you in the right direction more accurately.


Rick Jackson
Survey CAD Technician VI

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature

Message 3 of 26

Dambrowski
Contributor
Contributor

I'm going to put a figure, what I need, which is to show a block with a label, in a certain coordinate.

captura1.png

I thought of two solutions, an Excel spreadsheet, with the data I need, but I don't know how to load it and show it in Autocad.

Dambrowski_0-1713289470712.png

would be to load a coordinate with a specific block and a specific size and show a label.

 

I also tried with a lisp, it worked but I couldn't show the label...(A20) (A21) (A22)...

(defun c:lisp_a () (command
"insert" "t24" "100,100" "1" "1" "0"
"insert" "t24" "200,200" "2" "2" "0"
"insert" "t24" "300,300" "5" "5" "0"
))

 

Any help is welcome, it seems very simple, but I'm not getting it. I thank

0 Likes
Message 4 of 26

jeff.wangD95HG
Collaborator
Collaborator

I dont think you need a lisp for this.

this can probably be done using description key functionality

I am just going to give a few keyword for you to research and will go in depth if you need

the excel CSV set up should look something like this

 

PT#, Northing, Easting, height, BlockName scale, description

Make special note that BlockName and Scale is separated by Space and not by comma

This is a PNEZD point format with additional attributes.

and you can import CSV files as cogo points

 

jeffwangD95HG_0-1713294515221.png

make sure you set up the point style and label style which you may want to research on your own

go to description key and modify stuff and make sure you check the scale parameter

jeffwangD95HG_1-1713294655433.png

it will read the D element of PNEZD and take the element after the space.

 

from point style you should be able to get it  to display the needed block

description key will match it base on the block name to the point style that is created

label style you can set it to display the descriptions.

 

Its a lot of work to set up but once set up you can probably save it as a template and it will be really fast afterwards

 

 

 

 

Message 5 of 26

Dambrowski
Contributor
Contributor

I followed your steps, mounted the file and imported it, but I've never worked with a description key, I'll study it a bit, but from what I've seen, it should work for what I need.

I had already done something similar, but I couldn't define the size of the label, with the data from the .txt file.

I don't know where are these description keys but I'll study hehe thanks

 

I'll post what I did to see if it's correct.

1.jpg

2.jpg

0 Likes
Message 6 of 26

jeff.wangD95HG
Collaborator
Collaborator

raw description is incorrect. you had it reversed

it should be

t24 5

t24 9

t24 12

also the current set up of PnezD doesn't work because it doesn't read what is after D so you need to look at this video to add additional attritbute

 

(205) Points with Attribute Labels - YouTube

Message 7 of 26

Dambrowski
Contributor
Contributor

OK, thanks, I'll look and study.

but can I define the block size by imported attributes?

0 Likes
Message 8 of 26

jeff.wangD95HG
Collaborator
Collaborator

yes as long as you put it in the right spot and setted up correctly it should read base on description key

Message 9 of 26

Dambrowski
Contributor
Contributor

I managed to create and import all the attributes, just like in the video!

but I still don't understand how each block will take the size, which is loaded in the created attribute column, and apply it to it to get the desired size.

Same as the first image I sent today.

Dambrowski_0-1713309241354.png

the size will not be displayed on the label, it will only change the size of the block

0 Likes
Message 10 of 26

Pointdump
Consultant
Consultant

Hi Luis,
"the size will not be displayed on the label, it will only change the size of the block"
In addition to the Description Keys, you'll also need to create Label Styles reflecting the A20, A21, and A22 label sizes; and then seperate Point Groups Including A20, A21, and A22 Descriptions, with Label Style Overrides. A bit of work, but do-able.
Dave

Dave Stoll
Las Vegas, Nevada

EESignature

64GB DDR4 2400MHz ECC SoDIMM / 1TB SSD
NVIDIA Quadro P5000 16GB
Windows 10 Pro 64 / Civil 3D 2027
0 Likes
Message 11 of 26

jeff.wangD95HG
Collaborator
Collaborator

@Dambrowski 

 

forgot to tell you to check apply to x-y in description key

jeffwangD95HG_0-1713374261854.png

this is the final result

jeffwangD95HG_1-1713374281442.png

i also included drawing so you can possibly see where you went wrong

Message 12 of 26

Dambrowski
Contributor
Contributor

I believe I did it differently.....I haven't fixed the styles yet, but I'll fix that later.

The way I did it, it is possible to apply the value in the attribute, "block_size" to "x-y scale"

I didn't understand the part about your description keys....how to recognize the size value and apply it to the block.

1.jpg

2.jpg

0 Likes
Message 13 of 26

Dambrowski
Contributor
Contributor

What do I have... I just need the block to obey the block size value

0 Likes
Message 14 of 26

jeff.wangD95HG
Collaborator
Collaborator

"apply the value in the attribute, "block_size" to "x-y scale""

No because civil3d is trash like that. it has to be applied exactly the same way I did it. description key as the name suggest will ONLY read information in the description attribute and nothing else.

 

also looking at your screenshot you created an attribute for block name. civil 3d wont be able to read that with description key so you have to manually change the block for each point if you choose to do it that way.

 

"I didn't understand the part about your description keys....how to recognize the size value and apply it to the block"

perhaps this will help?

Solved: Scaling using Description Keys - Autodesk Community - Civil 3D

Message 15 of 26

Dambrowski
Contributor
Contributor

I need exactly the same thing as this post you sent me; But I didn't understand! 

Is there a lisp or another way?

 

I just need a block at a coordinate with a size.

0 Likes
Message 16 of 26

jeff.wangD95HG
Collaborator
Collaborator

"I need exactly the same thing as this post you sent me; But I didn't understand!"

I will try to explain in my own words but if that doesn't help then perhaps someone else can explain it better

 

Basically the PNEZD data import format with attribute for civil 3d to read. You are able to create additional attributes but the new attributes can only  be read as text (you can reference/display them with label styles) and can't be used for any form of calculation.

 

PNEZD (comma delimited) = point#, northing, easting, elevation, description

comma delimited = attritbutes are separated by commas

for our purpose we need to add one more attribute for it to display the Name(you defined it as description) because we need the ACTUAL description attribute for civil 3d to do some stuff while Name(you defined it as description) is just text for display purpose 

 

so the new data format should be

PNEZDA (comma delimited) = point#, northing, easting, elevation, description, attribute1(NAME)

The description key ONLY reads the description attribute has its built in data format but it is space delimited meaning it will read whatever is in the attribute as

code parameter1 parameter2 parameter3 ......

which is why I told you to write "tk2 5" and in the description key you told civil 3d that parameter1 is scale and apply it to x-y scaling.

 

"Is there a lisp or another way?"

Try asking ChatGPT then for a lisp. you already have the cogo points imported. Ask it to write a lisp that modifies the imported cogo point and update its x-y scale by matching the point numbers in your CSV. 

I don't try lisp anymore as its functionality is still too limited for me. I just write C# .net .dll stuff for civil 3d to run

Message 17 of 26

Dambrowski
Contributor
Contributor

This lisp is exactly what I need, but I wanted to change the values... that were read from a .txt file

(defun c:arvore () (command
"insert" "arvore" "100,100" "1" "1" "0"
"text" "100,100" "5" "0" "A1"
"insert" "arvore" "200,200" "2" "2" "0"
"text" "200,200" "5" "0" "A2"
"insert" "arvore" "300,300" "5" "5" "0"
"text" "300,300" "5" "0" "A3"
))

use the civil 3d 2018

0 Likes
Message 18 of 26

Dambrowski
Contributor
Contributor

what I got, with this error:

 

Command: ARVORE
; error: too many arguments

 

(defun c:arvore ()
(setq file_path "C:/Users/CAD2/Downloads/att.txt") ; Substitua pelo caminho do seu arquivo .txt
(setq file (open file_path "r"))

(if file
(progn
(while (setq line (read-line file))
(setq data (vl-string->list line ";")) ; Alterado para usar ";" como separador
(if (= (car data) "arvore") ; Verifica se o comando é "arvore"
(progn
(setq params (vl-string->list (nth 1 data) ",")) ; Separa os parâmetros por ","
(setq x_coord (nth 1 params))
(setq y_coord (nth 2 params))
(setq scale_x (nth 3 params))
(setq scale_y (nth 4 params))
(setq angle (nth 5 params))
(setq raw (nth 6 params))
(command "insert" raw x_coord y_coord scale_x scale_y angle) ; Corrigido para usar o valor correto do bloco
)
)
)
(close file)
)
(alert "Falha ao abrir o arquivo.")
)
)

0 Likes
Message 19 of 26

Dambrowski
Contributor
Contributor

Can you make me a video or a step by step guide? I tried to insert more points in your drawing that you sent me but they didn't scale the same as the ones you made, thank you in advance

0 Likes
Message 20 of 26

jeff.wangD95HG
Collaborator
Collaborator
Accepted solution

assuming you have my drawing open. The only step is import cogo point so type "importpoints" and select the CSV file and the format PNEZD ATT1 ATT2 ....

I attached my CSV so follow the layout and input the data EXACTLY where it should be.