Jump to content

Find where are stored information about an entity


MastroLube

Recommended Posts

Hello everyone!

 

I've a tool that allow to draw reinforcing steel. The problem is that the quote with the number of the steel bars is always "1" instead of the real number.. seems that the code is broken somewhere.

 

I get rid of that with a lisp I made long time ago:

(defun c:cb (/ selezione i n n_bare e x i valore oggetto_testo testo_originale testo_modificato)



 (setq selezione (ssget '((0 . "LINE,TEXT") (8 . "CB_Ferri,CB_Richiami"))))

       (setq i 0
             n (sslength selezione)
         n_barre 0
           )
           (repeat n
               (setq e (ssname selezione i)
                     x (cdr (assoc 0 (entget e)))
                     lay (cdr (assoc 8 (entget e))) 
                     i (1+ i)
               )
         (COND ( (and (equal x "LINE") (equal lay "CB_Ferri"))
         (setq n_barre (1+ n_barre)))
           ((equal x "TEXT")
              (setq valore (cdr (assoc 1 (entget e))))
              (IF (equal (substr valore 1 2) "1%")
                  (setq oggetto_testo e
                    testo_originale (substr valore 2 20))
                (princ)
            )
         
         )
           )
       )
(setq testo_modificato (strcat (itoa n_barre) testo_originale ))
(entmod (SUBST (CONS 1 testo_modificato) (ASSOC 1 (entget oggetto_testo)) (entget oggetto_testo)))




     

   )

As you can suppose it's a very long work and I have to do it again if renumber the steel bars!

 

I'm looking for something better.. But i didn't find where are stored all the information. If you get a dump you will find a dictionary with all these entities but I can't relate them.. Can someone help me with a tip?

 

 

I've attached a .dwg file wrong number.dwg.

 

Thanks, Dennis

Link to comment
Share on other sites

  • Replies 33
  • Created
  • Last Reply

Top Posters In This Topic

  • MastroLube

    18

  • Tharwat

    11

  • Lee Mac

    2

  • Roy_043

    2

Top Posters In This Topic

Posted Images

Hello! thanks for the reply :)

 

the number before the ∅: "1∅16/20 L=250" is always one, even when i select more bars..

Thanks

Link to comment
Share on other sites

yes, exactly.. sometimes even the number in the circle, which is the position number get messed (after a renumber) but usually I fix it with some tricks

Link to comment
Share on other sites

Just curious.

Why did you check if the first char is a number and it is equal to 1 in the following codes? although I don't think it is necessarily since the first char would be replaced with the correct number of selected lines after all. correct?

 

(equal (substr valore 1 2) "1%")

Link to comment
Share on other sites

Because I select more object at once, think of all of these bars in a complex drawing.. Anyway I don't want to select anything anymore XD I lisp should correct all of them in one click, if it's possible.. I think that the dictionary way is the only affordable.. But I can't relate the entities :(

 

Inviato dal mio LG-D855 utilizzando Tapatalk

Link to comment
Share on other sites

Try the following mods on your codes which I tried not to change the way of coding you did with the program so the program now should select lines on that specific layer ONLY and text(s) on that specific layer also besides that the text string of the text must start with number with two percentage symbols (%%).

 

Here we go:

 

(defun c:cb (/ selezione n n_barre e valore)
 (if (setq n_barre   0
           selezione (ssget '((-4 . "<OR")
                              (-4 . "<AND")
                              (0 . "LINE")
                              (8 . "CB_Ferri")
                              (-4 . "AND>")
                              (-4 . "<AND")
                              (0 . "TEXT")
                              (1 . "#%%*")
                              (8 . "CB_Richiami")
                              (-4 . "AND>")
                              (-4 . "OR>")
                             )
                     )
     )
   (progn
     (repeat (setq n (sslength selezione))
       (setq e (entget (ssname selezione (setq n (1- n)))))
       (if (= (cdr (assoc 0 e)) "LINE")
         (setq n_barre (1+ n_barre))
         (setq valore e)
       )
     )
     (if (and (> n_barre 0) valore)
       (entmod
         (subst
           (cons 1
                 (strcat (itoa n_barre) (substr (cdr (assoc 1 e)) 2))
           )
           (assoc 1 e)
           e
         )
       )
     )
   )
 )
 (princ)
)

Link to comment
Share on other sites

Try to select all of the bars (which is exactly what I want to do because in a complex drawing sometimes I miss some of them). I'll put the total number of the bars in the first text it will find.

 

So i get "23∅16/20 L=250" instead of ten! and other quotes still be at 1.

 

The entity text must be associated with the bars it quotes. this information should be in the dictionary (I think)

 

wrong number.dwg

Link to comment
Share on other sites

yes, that was exactly what I've do for more than a year :D

 

I'm looking for something better, but i need some help to accomplish that

Link to comment
Share on other sites

yes, in this case it is. but it's a variable i can change for each series of bars

 

Are the lines horizontal and there is that sort of text below them all the time?

Link to comment
Share on other sites

OK, I made a little easier .dwg with only one bar (diameter: 16mm, length: 235cm with the label "Pippo") , only one sequence of 7 bars (distance among them: 23 cm) with the two type of quote , the "on single bar" and the "or series of bars".

 

As before have dump in order to help me :D

 

prova.dwg

 

(defun cdrs (key lst / pair rtn)
(while (setq pair (assoc key lst))
(setq rtn (cons (cdr pair) rtn)
lst (cdr (member pair lst))
)
)
(reverse rtn)
)
(setq ENVIRONMENT_dict (dictsearch (namedobjdict) "AUTO_CA_ENVIRONMENT")
     Barra_dict (dictsearch (namedobjdict) "SETEC_AUTOCA_DZ_Barra")
     FERRO_dict (dictsearch (namedobjdict) "SETEC_AUTOCA_DZ_FERRO")
     GEN_BARRE_dict (dictsearch (namedobjdict) "SETEC_AUTOCA_DZ_GEN_BARRE")
     POS_FERRO_dict (dictsearch (namedobjdict) "SETEC_AUTOCA_DZ_POS_FERRO")
     POSIZIONAMENTO_FERRO_dict (dictsearch (namedobjdict) "SETEC_AUTOCA_DZ_POSIZIONAMENTO_FERRO")
     RICHIAMO_dict (dictsearch (namedobjdict) "SETEC_AUTOCA_DZ_RICHIAMO")
     )



(setq list_of_quotes (cdrs 350 RICHIAMO_dict))

I have 2 object there (good news!)

I entget both of them:

(entget (car list_of_quotes))

((-1 . <Nome entità: 7ff5ffba0570>) (0 . "XRECORD")
                                   (5 . "2B7")
                                   (102 . "{ACAD_REACTORS")
                                   (330 . <Nome entità: 7ff5ffba0560>)
                                   (102 . "}")
                                   (330 . <Nome entità: 7ff5ffba0560>)
                                   (100 . "AcDbXrecord")
                                   (280 . 1)
                                   (90 . 4)
                                   (90 . 7)
                                   (1 . "26A")
                                   (1 . "")
                                   (290 . 0)
                                   (40 . 0.0)
                                   (290 . 0)
                                   (290 . 1)
                                   (290 . 0)
                                   (290 . 1)
                                   (290 . 0)
                                   (290 . 0)
                                   (290 . 0)
                                   (290 . 0)
                                   (290 . 1)
                                   (40 . 0.0)
                                   (70 . 9)
                                   (70 . 0)
                                   (70 . 4)
                                   (70 . 3)
                                   (70 . 3)
                                   (70 . 253)
                                   (70 . 1)
                                   (40 . 1.6)
                                   (40 . 1.6)
                                   (40 . 0.0)
                                   (40 . 1.0)
                                   (1 . "CB_Richiami")
                                   (1 . "ACA_1")
                                   (1 . "ACA_1")
                                   (1 . "")
                                   (1 . "")
                                   (1 . "")
                                   (40 . 1.0)
                                   (290 . 1)
                                   (40 . -2.68906)
                                   (40 . 100.0)
                                   (40 . 0.5)
                                   (40 . 1.0)
                                   (1 . "1")
                                   (1 . "")
                                   (1 . "")
                                   (1 . "")
                                   (1 . "")
                                   (40 . 1.0)
                                   (290 . 1)
                                   (290 . 1)
                                   (40 . 95.0)
                                   (40 . 20.0)
                                   (70 . 0)
                                   (40 . 0.0)
                                   (40 . 0.0)
                                   (40 . 0.0)
                                   (40 . 0.0)
                                   (40 . 0.0)
                                   (1 . "")
                                   (40 . 0.0)
                                   (40 . 0.0)
                                   (40 . 0.5)
                                   (40 . 1.25)
                                   (40 . 0.0)
                                   (40 . 0.0)
                                   (70 . -1)
                                   (70 . 1)
                                   (40 . 1.4)
                                   (1 . "ACA_1")
                                   (1 . "")
                                   (290 . 1)
                                   (70 . 1)
                                   (290 . 1)
                                   (290 . 0)
                                   (1 . "")
                                   (40 . 0.0)
                                   (40 . 0.0)
                                   (290 . 0)
                                   (70 . -1)
                                   (290 . 1)
                                   (1 . "{IdBlocchiEstreminta")
                                   (1 . "2A0")
                                   (1 . "2A1")
                                   (1 . "IdBlocchiEstreminta}")
                                   (1 . "{IdTxtEtichetta")
                                   (1 . "2A2")
                                   (1 . "2A4")
                                   (1 . "2A3")
                                   (1 . "2AA")
                                   (1 . "2A9")
                                   (1 . "IdTxtEtichetta}")
                                   (1 . "{IdTxtCampiSerieBarre")
                                   (1 . "2A2")
                                   (1 . "IdTxtCampiSerieBarre}")
                                   (1 . "{PuntiPolilinea")
                                   (1 . "PuntiPolilinea}")
                                   (1 . "26B")
                                   (1 . "2AB")
                                   (70 . 1)
)

(entget (cadr list_of_quotes))

discovered that this is the quote we're looking for! something there is missed (maybe :D)

 

((-1 . <Nome entità: 7ff5ffba06a0>) (0 . "XRECORD")
                                   (5 . "2CA")
                                   (102 . "{ACAD_REACTORS")
                                   (330 . <Nome entità: 7ff5ffba0560>)
                                   (102 . "}")
                                   (330 . <Nome entità: 7ff5ffba0560>)
                                   (100 . "AcDbXrecord")
                                   (280 . 1)
                                   (90 . 4)
                                   (90 . 7)
                                   (1 . "2BB")
                                   (1 . "2C7")
                                   (290 . 0)
                                   (40 . 0.0)
                                   (290 . 0)
                                   (290 . 1)
                                   (290 . 1)
                                   (290 . 1)
                                   (290 . 0)
                                   (290 . 1)
                                   (290 . 0)
                                   (290 . 0)
                                   (290 . 0)
                                   (40 . 0.0)
                                   (70 . 6)
                                   (70 . 0)
                                   (70 . 0)
                                   (70 . 3)
                                   (70 . 3)
                                   (70 . 253)
                                   (70 . 1)
                                   (40 . 1.6)
                                   (40 . 1.6)
                                   (40 . 0.12)
                                   (40 . 1.0)
                                   (1 . "CB_Richiami")
                                   (1 . "ACA_1")
                                   (1 . "ACA_1")
                                   (1 . "1")
                                   (1 . "")
                                   (1 . "Pippo1")
                                   (40 . 0.0)
                                   (290 . 0)
                                   (40 . 0.0)
                                   (40 . 0.0)
                                   (40 . 0.0)
                                   (40 . 0.0)
                                   (1 . "")
                                   (1 . "Fine")
                                   (1 . "Fine")
                                   (1 . "media")
                                   (1 . "media")
                                   (40 . 1.0)
                                   (290 . 1)
                                   (290 . 1)
                                   (40 . 95.0)
                                   (40 . 20.0)
                                   (70 . 0)
                                   (40 . 0.0)
                                   (40 . 0.0)
                                   (40 . 0.0)
                                   (40 . 0.0)
                                   (40 . 0.0)
                                   (1 . "")
                                   (40 . 0.0)
                                   (40 . 0.0)
                                   (40 . 0.0)
                                   (40 . 1.25)
                                   (40 . 0.0)
                                   (40 . 0.0)
                                   (70 . 0)
                                   (70 . 256)
                                   (40 . 0.0)
                                   (1 . "")
                                   (1 . "")
                                   (290 . 1)
                                   (70 . 2)
                                   (290 . 1)
                                   (290 . 0)
                                   (1 . "2C9")
                                   (40 . 5.12238)
                                   (40 . 8.64344)
                                   (290 . 0)
                                   (70 . -1)
                                   (290 . 0)
                                   (1 . "{IdBlocchiEstreminta")
                                   (1 . "2BC")
                                   (1 . "2BD")
                                   (1 . "2BE")
                                   (1 . "2BF")
                                   (1 . "2C0")
                                   (1 . "2C1")
                                   (1 . "2C2")
                                   (1 . "IdBlocchiEstreminta}")
                                   (1 . "{IdTxtEtichetta")
                                   (1 . "2C8")
                                   (1 . "IdTxtEtichetta}")
                                   (1 . "{IdTxtCampiSerieBarre")
                                   (1 . "IdTxtCampiSerieBarre}")
                                   (1 . "{PuntiPolilinea")
                                   (40 . 2.99745)
                                   (40 . 8.64344)
                                   (40 . 4.70438)
                                   (40 . 8.64344)
                                   (1 . "PuntiPolilinea}")
                                   (1 . "43")
                                   (1 . "42")
                                   (1 . "41")
                                   (1 . "40")
                                   (1 . "39")
                                   (1 . "38")
                                   (1 . "37")
)

The entities "350" in "Barra_dict" are more than expected :/ 42 elements!

- I've deleted one bar and now they are 53

- I've restored it and now they are 81 lol

Don't know what they are but it must be a bug that will make the file big.. maybe I'll dig inside them

 

The entities in "FERRO_dict" is only one! good! we have only one type of bar!

That's is what there is inside it:

((-1 . <Nome entità: 7ff5ffbaee40>) (0 . "XRECORD")
                                   (5 . "394")
                                   (102 . "{ACAD_REACTORS")
                                   (330 . <Nome entità: 7ff5ffba0930>)
                                   (102 . "}")
                                   (330 . <Nome entità: 7ff5ffba0930>)
                                   (100 . "AcDbXrecord")
                                   (280 . 1)
                                   (90 . 2)
                                   (90 . 7)
                                   (1 . "1ED")
                                   (1 . "")
                                   (1 . "")
                                   (70 . 0)
                                   (70 . 0)
                                   (70 . 1)
                                   (70 . 1)
                                   (40 . 16.0) [color=red][b]this is the diameter of the bar[/b][/color]
                                   (40 . 2.35) [color=red][b]this is the length[/b][/color] 
                                   (40 . 5.04072) [color=red][b]this is the coordinate of x of the middle point of where is the type bar[/b][/color]
                                   (40 . 4.54486) [color=red][b]this is the coordinate of y of where is the type bar[/b][/color]
                                   (40 . 3.86572)[color=red][b] this is the coordinate of x of where is the type bar[/b][/color]
                                   (40 . 4.54486) [color=red][b]this is the coordinate of y of where is the type bar[/b][/color]
                                   (70 . 9)
                                   (40 . 0.5)
                                   (40 . 1.0)
                                   (40 . 0.0)
                                   (1 . "ACA_1") [color=red][b]this is the style[/b][/color]
                                   (70 . 1)
                                   (1 . "CB_Ferri") [color=red][b]this is the layer[/b][/color]
                                   (70 . 3)
                                   (1 . "media") [color=red][b]this is the style of line[/b][/color]
                                   (1 . "fine") [color=red][b]this is the style of line[/b][/color]
                                   (70 . 1)
                                   (40 . 0.0)
                                   (40 . 1.0)
                                   (40 . 100.0)
                                   (70 . 2)
                                   (290 . 1)
                                   (290 . 1)
                                   (40 . 95.0)
                                   (40 . 20.0)
                                   (1 . "1")
                                   (70 . 1)
                                   (1 . "{Sezione_FerroEsploso_01")
                                   (1 . "Sezione_FerroEsploso_01}")
                                   (1 . "{Sezione_FerroEsploso_02")
                                   (1 . "1F0")
                                   (70 . 0)
                                   (1 . "Sezione_FerroEsploso_02}")
                                   (1 . "{Sezione_FerroEsploso_03")
                                   (1 . "<VAR>")
                                   (1 . "000")
                                   (280 . 1)
                                   (70 . 0)
                                   (1 . "<GRPVAR>")
                                   (1 . "<VAR>")
                                   (1 . "a")
                                   (280 . 1)
                                   (70 . 7)
                                   (40 . 1.0)
                                   (40 . 0.0)
                                   (40 . 2.35)
                                   (40 . 0.0)
                                   (290 . 0)
                                   (1 . "</VAR>")
                                   (1 . "</GRPVAR>")
                                   (1 . "</VAR>")
                                   (1 . "Sezione_FerroEsploso_03}")
                                   (1 . "{Sezione_FerroEsploso_04")
                                   (1 . "Sezione_FerroEsploso_04}")
                                   (1 . "{Sezione_FerroEsploso_05")
                                   (1 . "Sezione_FerroEsploso_05}")
                                   (1 . "{Sezione_FerroEsploso_06")
                                   (1 . "1")
                                   (1 . "2")
                                   (1 . "Sezione_FerroEsploso_06}")
                                   (1 . "{Sezione_FerroEsploso_07")
                                   (40 . 0.0)
                                   (40 . 0.0)
                                   (1 . "Sezione_FerroEsploso_07}")
                                   (1 . "{Sezione_FerroEsploso_17")
                                   (1 . "Sezione_FerroEsploso_17}")
                                   (1 . "{Sezione_FerroEsploso_08")
                                   (1 . "1")
                                   (1 . "Sezione_FerroEsploso_08}")
                                   (1 . "{Sezione_FerroEsploso_09")
                                   (70 . 0)
                                   (1 . "Sezione_FerroEsploso_09}")
                                   (1 . "{Sezione_FerroEsploso_10")
                                   (70 . 0)
                                   (1 . "Sezione_FerroEsploso_10}")
                                   (1 . "{Sezione_FerroEsploso_11")
                                   (1 . "Sezione_FerroEsploso_11}")
                                   (1 . "{Sezione_FerroEsploso_12")
                                   (1 . "Sezione_FerroEsploso_12}")
                                   (1 . "{Sezione_FerroEsploso_13")
                                   (1 . "Sezione_FerroEsploso_13}")
                                   (1 . "{Sezione_FerroEsploso_14")
                                   (1 . "Sezione_FerroEsploso_14}")
                                   (1 . "{Sezione_FerroEsploso_15")
                                   (1 . "Sezione_FerroEsploso_15}")
                                   (1 . "{Sezione_FerroEsploso_16")
                                   (1 . "Sezione_FerroEsploso_16}")
)

Inside the "GEN_BARRE_dict" there is one entity: the generator of bars .It's the polyline in "CB_Generatrici" layer that allow me to modify how many bars , the orientation and the position.

((-1 . <Nome entità: 7ff5ffbaec30>) (0 . "XRECORD")
                                   (5 . "373")
                                   (102 . "{ACAD_REACTORS")
                                   (330 . <Nome entità: 7ff5ffba0b30>)
                                   (102 . "}")
                                   (330 . <Nome entità: 7ff5ffba0b30>)
                                   (100 . "AcDbXrecord")
                                   (280 . 1)
                                   (90 . 2)
                                   (90 . 5)
                                   (1 . "204")
                                   (1 . "1")
                                   (70 . 1)
                                   (70 . -1)
                                   (40 . 16.0)
                                   (70 . 3)
                                   (290 . 1)
                                   (290 . 0)
                                   (290 . 0)
                                   (290 . 0)
                                   (290 . 0)
                                   (290 . 0)
                                   (70 . 1)
                                   (70 . 1)
                                   (70 . 0)
                                   (1 . "1")
                                   (40 . 2.35)
                                   (40 . 1.5708)
                                   (40 . 0.0)
                                   (40 . 0.0)
                                   (40 . 0.0)
                                   (40 . 0.0)
                                   (40 . 0.0)
                                   (40 . 2.99745)
                                   (40 . 9.81844)
                                   (1 . "")
                                   (1 . "CB_Ferri")
                                   (1 . "")
                                   (290 . 1)
                                   (290 . 1)
                                   (40 . 1.0)
                                   (40 . 95.0)
                                   (40 . 20.0)
                                   (1 . "{ParametriCampiSB")
                                   (40 . 0.23)
                                   (40 . 0.23)
                                   (70 . 0)
                                   (70 . 7)
                                   (40 . 1.38)
                                   (40 . 2.99745)
                                   (40 . 7.46844)
                                   (40 . 4.37745)
                                   (40 . 7.46844)
                                   (40 . 0.0)
                                   (1 . "ParametriCampiSB}")
                                   (1 . "{PuntiInizialiBarre")
                                   (40 . 2.99745)
                                   (40 . 7.46844)
                                   (40 . 3.22745)
                                   (40 . 7.46844)
                                   (40 . 3.45745)
                                   (40 . 7.46844)
                                   (40 . 3.68745)
                                   (40 . 7.46844)
                                   (40 . 3.91745)
                                   (40 . 7.46844)
                                   (40 . 4.14745)
                                   (40 . 7.46844)
                                   (40 . 4.37745)
                                   (40 . 7.46844)
                                   (1 . "PuntiInizialiBarre}")
                                   (1 . "{PuntiFinaliBarre")
                                   (40 . 2.99745)
                                   (40 . 9.81844)
                                   (40 . 3.22745)
                                   (40 . 9.81844)
                                   (40 . 3.45745)
                                   (40 . 9.81844)
                                   (40 . 3.68745)
                                   (40 . 9.81844)
                                   (40 . 3.91745)
                                   (40 . 9.81844)
                                   (40 . 4.14745)
                                   (40 . 9.81844)
                                   (40 . 4.37745)
                                   (40 . 9.81844)
                                   (1 . "PuntiFinaliBarre}")
                                   (1 . "{PuntiGeneratrice")
                                   (40 . 2.99745)
                                   (40 . 9.81844)
                                   (40 . 2.99745)
                                   (40 . 7.46844)
                                   (40 . 4.37745)
                                   (40 . 7.46844)
                                   (1 . "PuntiGeneratrice}")
                                   (1 . "{BulgesGeneratrice")
                                   (40 . 0.0)
                                   (40 . 0.0)
                                   (40 . 0.0)
                                   (1 . "BulgesGeneratrice}")
                                   (1 . "77")
                                   (1 . "78")
                                   (1 . "79")
                                   (1 . "80")
                                   (1 . "81")
                                   (1 . "82")
                                   (1 . "83")
)

Again, inside the "POS_FERRO_dict" there is only one element:

((-1 . <Nome entità: 7ff5ffbaee50>) (0 . "XRECORD")
                                   (5 . "395")
                                   (102 . "{ACAD_REACTORS")
                                   (330 . <Nome entità: 7ff5ffba0950>)
                                   (102 . "}")
                                   (330 . <Nome entità: 7ff5ffba0950>)
                                   (100 . "AcDbXrecord")
                                   (280 . 1)
                                   (90 . 0)
                                   (90 . 2)
                                   (70 . 1)
                                   (70 . -1)
                                   (1 . "1F8")
                                   (1 . "1F9")
                                   (1 . "1FA")
                                   (1 . "")
                                   (1 . "1")
                                   (1 . "Ø Maiuscolo")   [color=red][b]this is of the phi must be[/b][/color]
                                   (1 . "CB_Ferri")   [color=red][b]this is the layer[/b][/color]
                                   (70 . 7)
                                   (40 . 23.0)
                                   (40 . 138.0)
                                   (1 . "1")
                                   (1 . "")
                                   (1 . "")
                                   (70 . 1)
                                   (1 . "Pippo") [color=red][b]this is the label[/b][/color]
                                   (1 . "")
                                   (290 . 1)
                                   (70 . 7)
                                   (40 . 0.0)
                                   (40 . 6.28319)
                                   (40 . 6.28319)
                                   (40 . 0.08)
                                   (40 . 1.0)
                                   (40 . 1.4)
                                   (40 . 1.4)
                                   (1 . "ACA_1")
                                   (70 . 3)
                                   (1 . "ACA_1")
                                   (70 . 3)
                                   (70 . 1)
                                   (290 . 1)
                                   (290 . 1)
                                   (290 . 1)
                                   (1 . "media")
                                   (1 . "media")
                                   (1 . "media")
                                   (1 . "fine")
                                   (290 . 0)
                                   (40 . 1.0)
                                   (290 . 1)
                                   (290 . 1)
                                   (40 . 95.0)
                                   (40 . 20.0)
                                   (290 . 1)
                                   (290 . 1)
)

And inside "POSIZIONAMENTO_FERRO_dict" only one element:

((-1 . <Nome entità: 7ff5ffba0990>)
 (0 . "XRECORD")
 (5 . "201")
 (102 . "{ACAD_REACTORS")
 (330 . <Nome entità: 7ff5ffba08a0>)
 (102 . "}")
 (330 . <Nome entità: 7ff5ffba08a0>)
 (100 . "AcDbXrecord")
 (280 . 1)
 (90 . 1)
 (90 . 1)
 (70 . 1)
 (70 . -1)
 (70 . 1)
 (40 . 16.0)
 (1 . "1")
 (40 . 0.0)
 (40 . 0.0)
 (40 . 0.0)
 (1 . "{Sezione Info sagoma ferro associato")
 (1 . "<VAR>")
 (1 . "000")
 (280 . 1)
 (70 . 0)
 (1 . "<GRPVAR>")
 (1 . "<VAR>")
 (1 . "a")
 (280 . 1)
 (70 . 7)
 (40 . 1.0)
 (40 . 0.0)
 (40 . 2.35)
 (40 . 0.0)
 (290 . 0)
 (1 . "</VAR>")
 (1 . "</GRPVAR>")
 (1 . "</VAR>")
 (1 . "Sezione Info sagoma ferro associato}")
 (1 . "{Sezione chiavi posizioni associate")
 (1 . "1")
 (1 . "Sezione chiavi posizioni associate}")
 (1 . "{Sezione associazione variabili posizione")
 (1 . "1")
 (1 . "{Sezione corrispondenza variabili posizione1")
 (1 . "a")
 (1 . "a")
 (1 . "Sezione corrispondenza variabili posizione1}")
 (1 . "Sezione associazione variabili posizione}")
)

Edited by MastroLube
Link to comment
Share on other sites

Excuse me Dennis, please edit your posts that have that long info which makes the thread a bit long and boring to read the posts.

 

try this program and select lines with texts that have the Diameter symbol in their strings.

 

NOTE: this program works ONLY with horizontal lines with gap 0.2 units between each line although you can edit this value from the program as indicated.

 

(defun c:Test (/ *error* gap ss in sn en l x p cad sp)
 ;;-----------------------------;;
 ;; Tharwat - Date: 23.Aug.2016 ;;
 ;;-----------------------------;;
 (defun *error* (m)
   (and sp (vla-zoomprevious cad))
   (and m (not (wcmatch (strcase m) "*BREAK*,*EXIT*,*CANCEL*"))
        (princ (strcat "\nError => " m))
   )
   (princ)
 )
 (setq gap 0.2);; Gap distance between lines
 (cond
   ((eq 4
        (logand
          4
          (cdr
            (assoc 70 (entget (tblobjname "LAYER" (getvar 'CLAYER))))
          )
        )
    )
    (alert "Current layer is locked !")
   )
   ((setq ss (ssget "_:L"
                    '((-4 . "<OR")
                      (-4 . "<AND")
                      (0 . "LINE")
                      (8 . "CB_Ferri")
                      (-4 . "AND>")
                      (-4 . "<AND")
                      (0 . "TEXT")
                      (50 . 0.0)
                      (1 . "*%%*")
                      (8 . "CB_Richiami")
                      (-4 . "AND>")
                      (-4 . "OR>")
                     )
             )
    )
    (repeat (setq in (sslength ss))
      (setq sn (ssname ss (setq in (1- in)))
            en (entget sn)
      )
      (if (= (cdr (assoc 0 en)) "LINE")
        (if (equal (cadr (cdr (assoc 10 en)))
                   (cadr (cdr (assoc 11 en)))
                   1e-4
            )
          (setq l (cons sn l))
        )
        (setq x (cons sn x))
      )
    )
    (vla-zoomextents (setq cad (vlax-get-acad-object)))
    (setq sp (vla-get-block
               (vla-get-ActiveLayout (vla-get-ActiveDocument cad))
             )
    )
    (mapcar
      '(lambda (o / lst r d f g q en st ch p)
         (if (setq lst nil
                   r   (vlax-invoke
                         sp
                         'addray
                         (setq p (cdr (assoc 10 (entget o))))
                         (polar p (* pi 0.5) 1.0)
                       )
             )
           (progn
             (mapcar '(lambda (e / pt)
                        (if (setq pt (vlax-invoke
                                       r
                                       'intersectwith
                                       (vlax-ename->vla-object e)
                                       AcExtendnone
                                     )
                            )
                          (setq lst (cons (list e pt) lst))
                        )
                      )
                     l
             )
             (vla-delete r)
             (if
               (and
                 lst
                 (setq lst (vl-sort lst
                                    '(lambda (j k)
                                       (< (distance p (cadr j))
                                          (distance p (cadr k))
                                       )
                                     )
                           )
                 )
                 (setq f (car lst)
                       g gap
                       q 0
                 )
                 (progn
                   (mapcar
                     '(lambda (_p)
                        (if
                          (equal g
                                 (setq a (distance (cadr f) (cadr _p)))
                                 1e-2
                          )
                           (setq q (1+ q)
                                 f _p
                           )
                        )
                      )
                     (cdr lst)
                   )
                   (if (< 0 q)
                     (setq q (1+ q))
                   )
                 )
                 (setq en (entget o)
                       st (cdr (assoc 1 en))
                       ch (vl-string-search "%%C" (strcase st))
                 )
               )
                (entmod
                  (subst (cons 1 (strcat (itoa q) (substr st (1+ ch))))
                         (assoc 1 en)
                         en
                  )
                )
             )
           )
         )
       )
      x
    )
   )
 )
 (*error* nil)
 (princ)
)(vl-load-com)

Link to comment
Share on other sites

Just for fun, have a look at the following video which shows how the program should work:

 

http://giphy.com/gifs/l2SpSddIehPz5zeMg

Thanks man! I will try it tomorrow! And try to clean all the post as well..

 

So do you think it is not a good idea dig inside dictionaries, right?

 

Inviato dal mio LG-D855 utilizzando Tapatalk

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...