Extract text from layer and fill into a certain table

Extract text from layer and fill into a certain table

ki76EPG
Explorer Explorer
1,115 Views
9 Replies
Message 1 of 10

Extract text from layer and fill into a certain table

ki76EPG
Explorer
Explorer

I have a drawing header with information I would like to draw to an existing table.

Is it possible with a lisp to get the text and write it in a certain place in a table (Maybe by clicking on the corner of the table.)

0 Likes
Accepted solutions (1)
1,116 Views
9 Replies
Replies (9)
Message 2 of 10

Sea-Haven
Mentor
Mentor

Ok 1st there are no Acad "TABLES" in sample dwg, rather text within line boxes, so maybe answer to your question is to set osnap to intersection and pick the lower left corner of 2 lines then you have a point to work from for the text input.

Offsets x=50 y=115

A fairly simple lisp calculation.

 

This may need some extras added but give it a try.

 

(defun c:txt2cnr ( / oldsnap txt pt)
(setq oldsnap (getvar 'osmode))
(setq txt (cdr (assoc 1 (entget (car (entsel "\nSelect text"))))))
(setvar 'osmode 32)
(setq pt (getpoint "\npick point for text "))
(setvar 'clayer "Tekst")
(setq pt (mapcar '+ pt (list 50 115 0.0)))
(command "text" pt "" "" txt)
(setvar 'osmode oldsnap)
(princ)
)
(c:txt2cnr)

 

 

 

0 Likes
Message 3 of 10

ki76EPG
Explorer
Explorer

It 

Is it possible to pick all text in a certain layer?

If I then have all single text in different layers, I could place it by the lisp.

0 Likes
Message 4 of 10

Moshe-A
Mentor
Mentor

@ki76EPG  hi,

 


@ki76EPG wrote:

Is it possible to pick all text in a certain layer?  YES

If I then have all single text in different layers, I could place it by the lisp. you did not gave us any relevant info to help you?


Say you picked these texts on a specific layer, now what? how do we know which text goes to which table\cell?

is there any criteria?

 

tell us how do you do it manually, post a dwg with a preview before and after.

 

Moshe

 

 

0 Likes
Message 5 of 10

ki76EPG
Explorer
Explorer

I have to move from the drawing header to the area "Betsy med lag".

Each different text is placed in a specific layer, and with running a lisp I would like to fille the area "Betsy med lag".

0 Likes
Message 6 of 10

ki76EPG
Explorer
Explorer

I think I have to pick the intersection in the area and from there place the text.

0 Likes
Message 7 of 10

Moshe-A
Mentor
Mentor

@ki76EPG 

 

i tried to match the numbers between header to the area "Betsy med lag" and could not find a match. maybe cause i don't speak your language so put the "Betsy med lag" near the header and draw a lines between the texts and their position in table. 

 

i'm now going to see the 1/4 final football game 😀

 

Moshe

 

0 Likes
Message 8 of 10

ki76EPG
Explorer
Explorer

What a game..

 

I try to show arraows for what I looking for and sent it again. It will first be monday mor ing, so good weekend ti your and Hopefully we get some great football this evening and tomorrow 

0 Likes
Message 9 of 10

calderg1000
Mentor
Mentor
Accepted solution

Regards @ki76EPG 

Here you have an alternative inserting data into an Acad table

(vl-load-com)
(defun c:insDat (/ ms nf nc pt numrows rowh colw mytab)
  (princ "\nEnter Enter Data in the Table...:")
  (setq H0  (getint "\nENTER VALUE H0JDE:")
        LÆ  (getint "\nENTER VALUE LÆNGDE:")
        TY  (getint "\nENTER VALUE TYKKELSE:")
        AN  (getint "\nENTER VALUE ANTAL:")
        VE  (getstring "\nENTER TEXT VENDEELEMENT:")
        EM  (getstring "\nENTER TEXT EMNE:")
        SA  (getint "\nENTER VALUE SAGSNR:")
        VÆT (getint "\nENTER VALUE VÆGT TOTAL:")
        VÆF (getint "\nENTER VALUE VÆGT FORPLADE:")
        VÆB (getint "\nENTER VALUE VÆGT BAGPLADE:")
        BU  (getint "\nENTER VALUE BUNDEN ARM:")
        NE  (getint "\nENTER VALUE NET:")
        EK  (getint "\nENTER VALUE EKSP.KL:")
  )
  (Setq ms
             (vla-get-Modelspace (vla-get-ActiveDocument (vlax-get-acad-object)))
        nf   15
        nc   3
        pt   (getpoint "\nData Table Insertion Point: ")
        rowh 350
        colW 1800
  )
  (setq mytab (vla-addtable ms (vlax-3d-point pt) nf nc rowh ColW))
                                                  ;Nfila,NColum,alt.Celda,ancho de celda
  (vla-setcolumnwidth mytab 0 600)
  (vla-put-StyleName mytab "Standard")
  (vla-put-HorzCellMargin mytab 50)
  (vla-SetTextHeight mytab (+ acDataRow acHeaderRow acTitleRow) 121.25)
  (vla-SetAlignment mytab acDataRow acmiddleleft)
  (vla-SetText mytab 0 0 "INFORMATIONER")
  (vla-SetText mytab 1 0 "Pos.:")
  (vla-SetText mytab 1 1 "EMNE")
  (vla-SetText mytab 1 2 "VÆRDI")
  (vla-SetText mytab 2 1 "H0JDE")
  (vla-settext mytab 2 2 (itoa H0))
  (vla-SetText mytab 3 1 "LÆNGDE")
  (vla-settext mytab 3 2 (itoa LÆ))
  (vla-SetText mytab 4 1 "TYKKELSE")
  (vla-settext mytab 4 2 (itoa TY))
  (vla-SetText mytab 5 1 "ANTAL")
  (vla-settext mytab 5 2 (itoa AN))
  (vla-SetText mytab 6 1 "VENDEELEMENT")
  (vla-SetText mytab 6 2 VE)
  (vla-SetText mytab 7 1 "EMNE")
  (vla-SetText mytab 7 2 EM)
  (vla-SetText mytab 8 1 "SAGSNR")
  (vla-SetText mytab 8 2 (itoa SA))
  (vla-SetText mytab 9 1 "VÆGT TOTAL")
  (vla-SetText mytab 9 2 (itoa VÆT))
  (vla-SetText mytab 10 1 "VÆGT FORPLADE")
  (vla-SetText mytab 10 2 (itoa VÆF))
  (vla-SetText mytab 11 1 "VÆGT BAGPLADE")
  (vla-SetText mytab 11 2 (itoa VÆB))
  (vla-SetText mytab 12 1 "BUNDEN ARM:")
  (vla-SetText mytab 12 2 (itoa BU))
  (vla-SetText mytab 13 1 "NET")
  (vla-SetText mytab 13 2 (itoa NE))
  (vla-SetText mytab 14 1 "EKSP.KL")
  (vla-SetText mytab 14 2 (itoa EK))
  (vlax-release-object mytab)
)

 


Carlos Calderon G
EESignature
>Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

Message 10 of 10

calderg1000
Mentor
Mentor

Regards @ki76EPG 

Try this code to select text data
ACAD and insert into the cells of the Table. Note that VENDEELEMENT and EKSP.KL are dynamic blocks.

 

(defun c:insDat1 (/ ms nf nc pt numrows rowh colw mytab)
  (Setq ms (vla-get-Modelspace (vla-get-ActiveDocument (vlax-get-acad-object))))
  (princ "\nSelect Data to insert into the Table...:")
  (setq H0  (princ(cdr (assoc 1 (entget (setq snh(car (entsel "\nSELECT VALUE H0JDE: ")))))))       
        LÆ  (princ(cdr (assoc 1 (entget (car (entsel "\nSELECT VALUE LÆNGDE: "))))))
        TY  (princ(cdr (assoc 1 (entget (car (entsel "\nSELECT VALUE TYKKELSE: "))))))
        AN  (princ(cdr (assoc 1 (entget (car (entsel "\nSELECT VALUE ANTAL: "))))))
        VE  (car (entsel "\nSELECT VALUE VENDEELEMENT: "));Block
        EM  (princ(cdr (assoc 1 (entget (car (entsel "\nSELECT VALUE EMNE: "))))))
        SA  (princ(cdr (assoc 1 (entget (car (entsel "\nSELECT VALUE SAGSNR: "))))))
        VÆT (princ(cdr (assoc 1 (entget (car (entsel "\nSELECT VALUE VÆGT TOTAL: "))))))
        VÆF (princ(cdr (assoc 1 (entget (car (entsel "\nSELECT VALUE VÆGT FORPLADE: "))))))
        VÆB (princ(cdr (assoc 1 (entget (car (entsel "\nSELECT VALUE VÆGT BAGPLADE: "))))))
        BU  (princ(cdr (assoc 1 (entget (car (entsel "\nSELECT VALUE BUNDEN ARM: "))))))
        NE  (princ(cdr (assoc 1 (entget (car (entsel "\nSELECT VALUE NET: "))))))
        EK  (car (entsel "\nSELECT VALUE EKSP.KL: "));Block
  )
  (Setq pt    (vlax-3d-point(getpoint "\nData Table Insertion Point: "))
        nf    15
        nc    3
        rowh  350
        colW  1800
        mytab (vla-addtable ms pt nf nc rowh ColW)
  )
  (vla-setcolumnwidth mytab 0 600)
  (vla-put-StyleName mytab "Standard")
  (vla-put-HorzCellMargin mytab 50)
  (vla-SetTextHeight mytab (+ acTitleRow) 140)
  (vla-SetTextHeight mytab (+ acDataRow acHeaderRow) 121.25)
  (vla-SetAlignment mytab acDataRow acmiddleleft)
  (vla-SetText mytab 0 0 "INFORMATIONER")
  (vla-SetText mytab 1 0 "Pos.:")
  (vla-SetText mytab 1 1 "EMNE")
  (vla-SetText mytab 1 2 "VÆRDI")
  (vla-SetText mytab 2 1 "H0JDE")
  (vla-settext mytab 2 2 H0)
  (vla-SetText mytab 3 1 "LÆNGDE")
  (vla-settext mytab 3 2 LÆ)
  (vla-SetText mytab 4 1 "TYKKELSE")
  (vla-settext mytab 4 2 TY)
  (vla-SetText mytab 5 1 "ANTAL")
  (vla-settext mytab 5 2 AN)
  (vla-SetText mytab 6 1 "VENDEELEMENT")
  (vla-SetText mytab 6 2 (strcase(DP VE)))
  (vla-SetText mytab 7 1 "EMNE")
  (vla-SetText mytab 7 2 EM)
  (vla-SetText mytab 8 1 "SAGSNR")
  (vla-SetText mytab 8 2 SA)
  (vla-SetText mytab 9 1 "VÆGT TOTAL")
  (vla-SetText mytab 9 2 VÆT)
  (vla-SetText mytab 10 1 "VÆGT FORPLADE")
  (vla-SetText mytab 10 2 VÆF)
  (vla-SetText mytab 11 1 "VÆGT BAGPLADE")
  (vla-SetText mytab 11 2 VÆB)
  (vla-SetText mytab 12 1 "BUNDEN ARM:")
  (vla-SetText mytab 12 2 BU)
  (vla-SetText mytab 13 1 "NET")
  (vla-SetText mytab 13 2 NE)
  (vla-SetText mytab 14 1 "EKSP.KL")
  (vla-SetText mytab 14 2 (DP EK))
  (vlax-release-object mytab)
)
;_
 (defun DP (s)
   (setq bdn (car (vlax-safearray->list
                     (vlax-variant-value
                       (vla-GetDynamicBlockProperties (vlax-ename->vla-object s))
                     )
                   )
              )
         nv   (vlax-get bdn 'value)
   )
 )

 

 


Carlos Calderon G
EESignature
>Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

0 Likes