Blocks in nodes with more than 2 lines

Blocks in nodes with more than 2 lines

Dan-Rod
Advocate Advocate
2,146 Views
31 Replies
Message 1 of 32

Blocks in nodes with more than 2 lines

Dan-Rod
Advocate
Advocate

Hello

 

I want to know how to add blocks to nodes where more than 2 lines come out, I have 2 blocks, one exclusive for 3 lines (3R), and another for more than 4 lines that come out of the same node (4R).

 

Attached file with blocks and an example of lines already with overlapping blocks.

 

I hope you can support me.

 

0 Likes
Accepted solutions (4)
2,147 Views
31 Replies
Replies (31)
Message 21 of 32

Dan-Rod
Advocate
Advocate
It works, is it possible that at the end it will extract a .csv with the final list of all the blocks that were inserted with the description 3R or 4R?
0 Likes
Message 22 of 32

ronjonp
Advisor
Advisor

@Dan-Rod wrote:

it works, is it possible that at the end it will extract a .csv with the final list of all the texts that were inserted?


What information do you need ? Number of 3's vs 4's ? Points where these labels occur? It's definitely possible to do .. see if you can make this work for you. Lee has the functions as well as examples of usage.

0 Likes
Message 23 of 32

Kent1Cooper
Consultant
Consultant

DATAEXTRACTION, perhaps?

Kent Cooper, AIA
0 Likes
Message 24 of 32

Dan-Rod
Advocate
Advocate

It works, is it possible that at the end it will extract a .csv with the final list of all the blocks that were inserted with the description 3R or 4R?

0 Likes
Message 25 of 32

Dan-Rod
Advocate
Advocate

The list of all the inserted texts, and if possible the coordinate where it is inserted, if not, only the complete list, this to be used as BOM

0 Likes
Message 26 of 32

Dan-Rod
Advocate
Advocate

I have used it, I wanted to see if this code already had it to save steps
0 Likes
Message 27 of 32

Dan-Rod
Advocate
Advocate

@Kent1Cooper
@ronjonp

The 2 lsp gave a solution to my problem, would it be possible for me to add the .csv extraction to the codes?

With extracted data I could remove it but I would like to avoid taking more steps

In case it is not possible, I appreciate your support.

0 Likes
Message 28 of 32

Kent1Cooper
Consultant
Consultant
Accepted solution

@Dan-Rod wrote:

.... would it be possible for me to add the .csv extraction to the codes? ....


Something like this?

(defun C:TEST (/ liness file n ldata ptlist thispt thisss blk)
  (if (setq liness (ssget "_X" '((0 . "LINE")))); add Layer filter if desired
    (progn ; then
      (setq file (open "C:/TEMP/TEST.CSV" "w")); <--EDIT file path/name
      (repeat (setq n (sslength liness)); make list of all Line endpoints
        (setq
          ldata (entget (ssname liness (setq n (1- n))))
          ptlist (cons (cdr (assoc 10 ldata)) ptlist); add start point
          ptlist (cons (cdr (assoc 11 ldata)) ptlist); add end point
        ); setq
      ); repeat
      (while ptlist
        (setq
          thispt (car ptlist); first remaining
          thisss (ssget "_C" (polar thispt (/ pi 4) 2) (polar thispt (* pi 1.25) 2) '((0 . "LINE,INSERT")))
            ;; 2 argument based on sample drawing AS CORRECTED, to find Block as well as Lines if present
        ); setq
        (if
          (and
            (not (ssget "_P" '((0 . "INSERT") (2 . "3R,4R")))); not already a Block there
            (> (sslength thisss) 2); more than 2 Lines meet there
          ); and
          (progn ; then
            (command "_.insert" (setq blk (if (= (sslength thisss) 3) "3R" "4R")) "_non" thispt "" "" "")
            (write-line (strcat blk "," (rtos (car thispt)) "," (rtos (cadr thispt)) "," (rtos (caddr thispt))) file)
          ); progn
        ); if
        (setq ptlist (vl-remove thispt ptlist)); remove all same point from list
          ;; will not remove if not exactly meeting; some may remain in list,
          ;; which is why above checks whether already a Block there
      ); while
      (close file)
    ); progn
  ); if
  (prin1)
)

Follow the EDIT instruction.  In the corrected sample drawing, it made a .CSV file that looks like this in Excel:

Kent1Cooper_0-1680790092100.png

and like this in Notepad:
3R,864.7452,135.122,0
3R,798.5671,135.122,0
4R,717.1359,135.122,0
4R,466.1691,135.122,0
3R,350.0266,135.122,0

 

It could be made to put a header line in labeling those columns as Block Name, X coordinate, Y coordinate, Z coordinate.  Or the Z could be omitted if it will always be 0.  You can mess around in other ways with exactly what information you want included.

Kent Cooper, AIA
0 Likes
Message 29 of 32

ronjonp
Advisor
Advisor
Accepted solution

@Dan-Rod I updated the code here to give you a tally of 3's and 4's.

ronjonp_0-1680792059730.png

0 Likes
Message 30 of 32

Dan-Rod
Advocate
Advocate

@Kent1Cooper 

 


excellent, thank you very much, as I commented, the 2 solutions help me and the best thing is that they are 2 different ways, best regards

0 Likes
Message 31 of 32

Sea-Haven
Mentor
Mentor

Just a comment do you need a table as well ? The int points to be numbered &  labelled maybe then sent to Excel would make sense to me.

 

0 Likes
Message 32 of 32

ronjonp
Advisor
Advisor

@Sea-Haven wrote:

Just a comment do you need a table as well ? The int points to be numbered &  labelled maybe then sent to Excel would make sense to me.

 


Common points of 3 and 4 don't make sense to tally locations for me other than how many of them there are. If you have the points in a spreadsheet then you need more code to pull that data and find them. @Sea-Haven Write it up if the OP actually needs that.

0 Likes