Autogenerate drawing by scripting

Hi all

I am new to BricsCAD (I have a little CAD experience) but I have done plenty of programming over the years (c, perl, java, c#, php, javascript ... )

I want to automate some tasks we do in BricsCAD that are similar in every project. Thinking of making a program that generates a project specific script that basically will open a drawing, insert a few blocks (from file system path) change their attributes, save and close drawing.

Some of the blocks are aggregations of other blocks and it seems they need to be 'exploded' before the attributes can be changed.

I would appreciate if someone could point me in the right direction: I see there is lisp but also some kind of simpler script-engine; what should I go with and are there any good tutorials or examples.

Been looking but what I've found is for AutoCAD. Well, I have the Developer Ref. and a general idea of what lisp is.

Cheers

-Mark-

Comments

  • Hi Mark, if it works for AutoCAD it works for BricsCAD as well in general. Scripting by chaining commands in a text file is a solution but you'll be limited at some point. What you might want to do is create a file "on_doc_load.lsp" in %programfiles% under Bricsys/etc./Support. In that file you create a line (load "procedure"). procedure.lsp (or something else) will be loaded, executed if it is in the search path, for every new and existing drawing. In this file you can add lines for commands, like (command "._-insert" "blockname" ...) (you may want to check first if "blockname" is in the document already) but also smarter things like changing attributes without exploding, search for example for "cad lisp tblsearch attributes". Hope this gives you a starting point. One thing: try to understand the concept of LISP, in particular data type "list", as an addition to your current skill set. Then you can approach challenges in an object oriented way, the "vl*" functions, and old school based.

  • Thanks a lot, making som progress now :)

  • You did not say what changes between the various versions of the drawings you need to create. But, regardless, I had what may be a comparable issue. Although, in my case, I was just wanting to insert a fairly simple block, that was sized based on dimensions from a vendor's catalog. Dynamic blocks would have been the obvious answer, except that BricsCAD does not support authoring Dblocks, or tables present in existing Dblocks that were created in AutoCAD.

    My approach was to write a VBA routine for use inside of Excel. Then, in Excel, I have one tab that has the data, and a 2nd tab that has a script on each line. The VBA first sees what line your cursor is on, and then copies the line of text from the same line in the script tab into the clipboard. Then, it opens a new BricsCAD drawing, and pastes the text that was in the clipboard. Then it converts everything into a block, and copies it to the clipboard. It closes that temporary drawing, and then finally, it pastes the block into BricsCAD.

    For me, since the block was fairly simple, this was the best approach. The actual script is up to the user, but in my version, I did use blocks to put some of the more complex shapes onto my new block.

    There were a few threads, some long, that I had started as I was learning how to make it all work. The main issue I ran into, was that I didn't realize that both Excel and BricsCAD need to be set up to "run as administrator" on my company computer. I posted the final working version on a new thread, to make it easy for others to find.

    A working Excel Spreadsheet with VBA to draw objects in BricsCAD - BricsCAD Forum
    https://forum.bricsys.com/discussion/32858/a-working-excel-spreadsheet-with-vba-to-draw-objects-in-bricscad

    -Joe

This discussion has been closed.

Howdy, Stranger!

It looks like you're new here. Click one of the buttons on the top bar to get involved!