[Sorce Code] Block import from csv

[Sorce Code] Block import from csv

DonatasAzaravicius
Advocate Advocate
3,293 Views
8 Replies
Message 1 of 9

[Sorce Code] Block import from csv

DonatasAzaravicius
Advocate
Advocate

Hi,

I have written lisp code to import blocks from csv file with attributes. And I want to share it.

To run the lisp first you will need to install OpenDCL for GUI.

GUI_BlockImport.odcl have GUI code made using OpenDCL, you can open and edit it using OpenDCL.

GJM_BlockImport.lsp have all lisp code.

You may need to add (vl-load-com) to lsp file if you get errors.

To run code enter GJM_BlockImport in AutoCAD command line. You should get this windowBlockImportInit.png

 

 

Symbol Location points to block definition. Is it in current drawing or in other dwg file.

CSV file: (name of last used csv file).

After pressing button "IMPORT" you will need to choose csv file with block data.

Block data in csv file should look like this:

Block name ; X coordinate ; Y coordinate ; Z coordinate ; Attribute1 ; Attribute2 ; ...

After choosing csv file you will get popup window telling about error or window like this:BlockImportFinish.png

 Now just press OK button and all blocks will be inserted.

 

 

This is in beta 🙂

So here may be bugs. If you find bugs write about it here.

 

 

I will try to add block export in this lisp in future. In my view it should work like this:

Add new button "EXPORT".

After pressing button "EXPORT" you will be asked to select one block in drawing. Lisp will select all blocks with same name in drawing and show data in window (like above image). After pressing OK you would be asked for csv file location and name. And lisp will export all data to csv file.

Accepted solutions (2)
3,294 Views
8 Replies
Replies (8)
Message 2 of 9

DonatasAzaravicius
Advocate
Advocate
Accepted solution

like wrote before. I had added export functionality and few more little things.

Export.png

Like block preview and header checkbox. If your csv file have header, you need to check it, so first line will be ignored.

If header are checked at export, exported csv file will have header line.

Will it export or import can be seen from bold name of button. In image I attached export, data will be exported.

Works only in model space. In future I may add paper space too.

 

0 Likes
Message 3 of 9

Anonymous
Not applicable

This is not working for me.  When I input the command 'GUI_BlockImportExport' I get the following error:

 

Project failed to Load!

The file could not be found or an error occurred while reading the file.

[GUI_BlockImportExport]

 

Then I get an OpenDCL Runtime Error:

An OpenDLC function argument processing exception has occurred!

Error: NIL value not allowed

Functions: dlc-Form-Show

Argument: 0

 

What I'm I doing wrong or missing here...

0 Likes
Message 4 of 9

jtm2020hyo
Collaborator
Collaborator

hello, can you add a "rotation value" column?

0 Likes
Message 5 of 9

devitg
Advisor
Advisor

I got it 

Command: GUI_BLOCKIMPORTEXPORT
OPENDCL Unknown command "OPENDCL".  Press F1 for help.

Command: ; error: no function definition: DCL_PROJECT_LOAD

How can I fix. 

0 Likes
Message 6 of 9

Anonymous
Not applicable

Download OpenDCL.Studio.ENU 

 

https:// www.opendcl.com/download/

0 Likes
Message 7 of 9

Sea-Haven
Mentor
Mentor

For a lot of us that have been around a while just being able to get some people to understand how to run a lisp yet alone that they must also go and download an external program to make the code work can be just to much. I understand Opendcl is a great tool but have stayed away from it for that reason of the end user coming back with "does not run". The program looks good this is just a suggestion make sure next time to say must have Opendcl installed.

 

OpenDCL Download

0 Likes
Message 8 of 9

bimFVC9B
Explorer
Explorer

Thanks for sharing the code, I was looking for it for a long time.
It could be implemented to add other blocks with attributes at the same time.

0 Likes
Message 9 of 9

DonatasAzaravicius
Advocate
Advocate
Accepted solution

Hi,

I have made it long ago, but had not shared it, but because you have made mee remember it I have shared my new Block Import Export with multiple blocks.

You can find them here