Adding dynamic block from excel file

Adding dynamic block from excel file

maria.stachura
Observer Observer
791 Views
4 Replies
Message 1 of 5

Adding dynamic block from excel file

maria.stachura
Observer
Observer

Hi! 🙂

I am young student just starting my way in lisp coding and I need a little help.

I am trying to add from excel file dynamic blocks to dwg file, that will appear in certain locations writen in csv/xlsx file. It supposed to look like this:

 tag.png

The tricky part is that I have to write a LISP doing it automaticlly. Can someone please help? 🙂

Thanks in advance!

In attached files I am adding excel file with sample coordinates.

0 Likes
792 Views
4 Replies
Replies (4)
Message 2 of 5

TheCADnoob
Mentor
Mentor

Check out the Lisp forum

 

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/bd-p/130

 

Also i would look into 

 

https://www.theswamp.org/

 

CADnoob

EESignature

0 Likes
Message 3 of 5

jvasUUKFX
Explorer
Explorer

If you need to create the block from scratch, that's beyond me (from LISP).  If the block definition already exists within the drawing file, then that's easier.  You should be taking parts of the sample LISPS already included with AutoCAD and from the web to do find the code sections you need for your algorithm.  The tasks you are needing to do are:

  • open excel file;
  • make list from excel file data;
  • (looping from your list) insert (pre-defined) dynamic block at user-specified coordinates;

From there you have one of two options.  You can make your LISP either assign the block attributes at the time of insertion, or you can make your LISP use the ENTLAST command inside of your loop to select the block and re-attribute it.

 

There are sample LISP files installed with AutoCAD which can do much of this.

0 Likes
Message 4 of 5

DumR0
Advocate
Advocate

Hi,

you need learn VBA programing for that not lisp

 

0 Likes
Message 5 of 5

jvasUUKFX
Explorer
Explorer

Not exactly true.  They don't need to learn VBA.  It's just a lot easier for dynamic blocks.  But there are things that LISP does better than VBA.  And block attribute handling is one.

 

VisualLISP handles dynamic blocks, clumsily.  The best documentation for VLISP commands affecting dynamic block properties are actually found on the Bricsys website for BricsCAD (https://developer.bricsys.com/bricscad/help/en_US/V22/DevRef/index.html)

 

The following line is a simple (and I use the term relatively) example of how to get a dynamic property (vla-getdynamicblockproperties) from a block (stored in variable "venam") and sets that value to a variable (pblst) for later use:

 

(setq pblst (vlax-variant-value (vlax-get-property (nth 0 (vlax-safearray->list (vlax-variant-value (vla-getdynamicblockproperties venam)))) "Value")))

 

Setting dynamic block values is much more complicated, because you need to know how to create and modify safe-array objects.

 

In OP's situation, I suspect that the block definition already exists and they are simply setting attribute values.  So, this wouldn't be an issue.

 

 

0 Likes