Coordinate table lisp

Hello, I don't know if anyone could help me.

I am looking for a lisp that, by selecting a polyline, inserts a numbered block at the vertices and generates a table of coordinates, putting the point number and the X and Y coordinates. Each data in a column of the table. And yes, the data can be generated with fields. This way, if you change any position point, the table is updated.

Searching I found some routine that does almost everything, except putting the data with fields.

Thank you so much

Comments

  • Hello.

    It appears that sub-entities (vertices) are not available to be used with fields.

    An alternative could be to create a reactor and assign it to the polyline.

    Or, to create separate function (not reactor) to update the table (tables) and call it after the polyline (polylines) is (are) edited.

  • Kentral
    edited September 25

    The fields of the table would be linked to the block that is inserted in the vertices. This way you will have a field with the block number, another with the x coordinate and another with the y coordinate.

  • Hello.

    It appears that the intent is to stretch the polyline together with the blocks placed in the polyline's vertices.
    This would mean that the polyline and one or more blocks are first selected.
    Then, by stretching a grip, the polyline's vertex and the block placed in that vertex will move together.

    If this is the case, then, indeed, the coordinates could be taken from the insertion point of the block.

    For this workflow, I attached a very basic approach that could be used as a start point to create the desired lisp script.
    As block number, I used an attribute.

  • Thank you.

    I get an error when selecting the polyline. Creates the table but does not insert blocks.

    ; error : Automation Error 80200030; [IAcadModelSpace] Error accessing [INSERTBLOCK] method. ErrIndex=0;
    Can't open file: 'Pos'.


    Could it be why I use Bricscad in Spanish?

  • Hello.

    The lisp script I attached is just a template, a starting point.
    It doesn't work with any drawing.

    To work fine, it should be adjusted to the specific conditions in which it is used.
    'Pos' is the name of the block I used for testing.
    You should adjust this name.

    The same thing is valid for the attribute name.
    For testing I used 'PTNR'.
    You should also adjust this name to fit your case.

  • Kentral
    edited September 26

    Thank you so much.I already modified it my way.Just one question.I have a folder with the blocks that I usually use.The routine could be modified to insert a block from that folder.In autocad I have some routines that simply putting the name of the block in the code already "searches" for it.

  • Hello.

    The path to the location where the blocks are stored should be added to the SRCHPATH variable, the best way is to use the SETTINGS command.

    With the lisp code that inserts the block, you might need to put the whole name of the file, including the ".dwg" extension:
    (vla-insertblock model inspt "block_name.dwg" sx sy sz rot)

  • Perfect.

    Thank you so much

  • Just one last thing, you can put in the code that asks for the insertion point of the table, not make it 0.0 by default.

  • Hello.

    You could remove the point from the first assignment code sequence.
    (setq app (vlax-get-acad-object)
    doc (vla-get-ActiveDocument app)
    model (vla-get-ModelSpace doc)
    )

    Then you could ask for a point:
    (setq pt (getpoint "\nTable insertion point: "))

    If a point is picked, the procedure should go on.
    Otherwise, it should stop.
    (if pt
    (setq pt (vlax-3d-point pt))
    (exit)
    )

    This is only a very basic approach.
    It should be further improved, depending on the case.

  • Kentral
    edited September 26

    Thank you so much.
    
    I didn't know how to make those options work, but ChatGPT solved it for me.
    
    Again thank you very much for everything
    

  • You can use this global program to choose a block if you have say a limited number of blocks to choose from.

    (if (not AH:Butts)(load "Multi radio buttons.lsp")) ; loads program

    (if (= but nil)(setq but 1)) ; this is needed to set default button
    ; you can reset default button to user pick
    ; (setq ans (ah:butts but "V" '("A B C D " "A" "B" "C" "D" ))) ; ans holds the button picked value as a string