Insert multiple blocks wuth different labels.

Hi everyone,

I would like to write a script that works in BricsCAD. I have a TXT file with about 100 lines, containing many points in the format X, Y, Z and the point name.

I already created a block called N000 in BricsCAD, and this block has an attribute where the point name should be inserted.

What I would like to achieve is that the script automatically inserts the block at the given coordinates from the TXT file, and fills the attribute with the point name. Unfortunately, I haven’t been able to accomplish this so far.

Has anyone done something similar or could provide an example?

Any help would be greatly appreciated!

Thanks in advance!

Comments

  • hi,

    this post can help: https://forums.augi.com/showthread.php?57242-Insert-block-using-coordinates-in-a-txt-file

  • Looking at example you can add the attribute value when you insert a block.

    (command "-insert" "blockName" xyData "1" "1" "0" attstring)
    

    This will add a single attribute value but if you have more attibute's in the block you can add more values, BUT and a big but you must match how many attributes there are. In saying that you can get around it with code filling in only certain attributes, Also make sure ATTREQ is set to 1. This means accept an attribute.

    A good idea for future requests is post a sample txt file, A few lines dont need a 100, A txt file or a csv which is more common for this task will show how the values X Y Z PTNo are separated per line. Depending on the "delimeter" as how the data is read, You may still want to do that.

  • aridzv
    edited November 1

    see the attached lisp ,"PT_BLK" block and txt sample file.

    1. Make sure "PT_BLK" block is inserted to the drawing.
    2. the lisp will create a layer for the points named "CSV_BLK_POINTS"
    3. then the lisp will insert the block "PT_BLK" in every point in the .TXT file to the drawing at "CSV_BLK_POINTS" layer and populate its attributes with "PNUMBER X Y Z"

    share your block here to edit the lisp to your needs.

  • Learnt something today. Still learning nearly 50 years of lisping.

    (setq linedata (read (strcat "(" linedata1 ")")))

    I just do this saves a few If's and buts

    (if (not (tblsearch "BLOCK" "PT_BLK")) ;maim if
    (progn
    (alert "Block PT_BLK Not Inserted in Drawing \n\nWill now exit \n\nPlease paste block into dwg ") ;; if PT_BLK not in the drawing
    (exit)
    )
    )

    As the block contains 4 attributes no need for tag names just populate using creation order.

        (setq vlablkatts (vlax-invoke  (vlax-ename->vla-object blk)'getattributes))
    ;(LM:vl-setattributevalue vlablk "Pname" desc)
    ; (LM:vl-setattributevalue vlablk "Px" (rtos px 2 3))
    ; (LM:vl-setattributevalue vlablk "Py" (rtos py 2 3))
    ; (LM:vl-setattributevalue vlablk "Pz" (rtos pz 2 3))
    (vlax-put (nth 0 vlablkatts) 'textstring desc)
    (vlax-put (nth 1 vlablkatts) 'textstring (rtos px 2 3))
    (vlax-put (nth 2 vlablkatts) 'textstring (rtos py 2 3))
    (vlax-put (nth 3 vlablkatts) 'textstring (rtos pz 2 3))

    Also I always acknowledge when using some one else's code the authors name, just a respect thing.

    ; Lee-mac set attributes
    (defun LM:vl-setattributevalue ( blk tag val )