Jump to content

Recommended Posts

Posted

Hi guys, :)

 

Attachment: Test Drawing.dwg

 

I want to retrive the text's content, the text is placed at a certain XYZ co-ordinate in Autocad, (same coordinates, always for all the drawings).

 

[Refering to the attachment]: The text below the "Surface Area" and the "Weight", are mostly the texts i'm trying to get.

 

These texts sometimes come as a single line text or as a mtext or within blocks..

but always they appear at the same coodinates.

 

Can somebody help me with this?

Posted

I think this text should be part of title block and reside in it as attribute values... So I strongly suggest that you keep title blocks as they are - do not explode them (burst)... In this way you will be able to easily get attribute values based on their tag names... The drawing you posted is inadequate for your specific request - it even doesn't matter if the position of text is the same - your drawings that have title block can be placed independently of UCS origin, but if they are prepared for batch plot or publish I also suggest that they don't change position... So please revise all your DWGs so that they have title block with which you can easily manipulate extract data or change values of texts/fields...

Posted

Thanks for the reply marko,:)

the drawings are being created by a piping software which mass publishes the drawings, :unsure:

and it doesn't create the values as block attributes...:oops:

also the drawing which was attached before was a representation drawing, I'm sorry :( but I couldn't give you the drawing since its confidential drawing of my office...

is there a way to get the text value from the drawing at the co-ordinates

 

PS:

My idea was for retriving the data; was to convert the drawings to dxf, use a text finding program to find the text beneatht the dxf codes using regex.

(AcDbText

10

205.6000061

20

11.89999962

30

0

40

2

1

0.787719

7

)

Posted

Try this not tested

 

(setq ss (SSGET "C" '(2 2) '(0 0) ))

(if (/= ss nil)(princ "Object found")(exit)) ; note exits if nothing found

(if (> (sslength ss) 1 )(exit)) ; to many objects

(setq obj (vlax-ename->vla-object (ssname ss 0)))

(setq isname (vla-get-Objectname obj))

(if (= isname "AcDbText")(alert "Text String found " (vla-get-textstring obj)))

(if (= isname "AcDbMText")(alert "MText String found " (vla-get-textstring obj)))

Posted

Thanks for the code BIGAL.:)

 

I tried to alter the code from there, but AutoCAD says "Object found; error: too many arguments"...:oops:

 

 

(defun c:test5 ()
 (setq
   point1 '(496.344 -32.5268 0.0)
   point2 '(514.247 -41.9455 0.0)
 )
 (setq ss (ssget "C" point1 point2))
 (if (/= ss nil)(princ "Object found")(exit)) ; note exits if nothing found
(if (> (sslength ss) 1 )(exit)) ; to many objects
(setq obj (vlax-ename->vla-object (ssname ss 0)))
(setq isname (vla-get-Objectname obj))
(if (= isname "AcDbText")(alert "Text String found " (vla-get-textstring obj)))
(if (= isname "AcDbMText")(alert "MText String found " (vla-get-textstring obj)))
)

 

Posted

Something like this?

 

(defun c:Test  (/ ss i lst)
 ;; Tharwat - 12.Jul.2016 ;;
 (if (setq ss (ssget "_C"
                     '(496.344 -32.5268 0.0)
                     '(514.247 -41.9455 0.0)
                     '((0 . "*TEXT"))))
   (progn
     (repeat (setq i (sslength ss))
       (setq lst
              (cons
                (cdr (assoc 1 (entget (ssname ss (setq i (1- i))))))
                lst))
       )
     (if (and lst (< (length lst) 11))
       (alert
         (strcat "Text string(s) :\n"
                 (apply 'strcat
                        (mapcar '(lambda (o) (strcat o "\n"))
                                (reverse lst)))))
       (progn
         (princ "\nText string(s) :\n")
         (mapcar '(lambda (o) (princ (strcat o "\n")))
                 (reverse lst))
         (textscr)
         )
       )
     )
   (princ "\nNo text(s) found !")
   )
 (princ)
 )

Posted

Ah, :shock:

just the one I was looking for... :)

 

Thank tharwat,

I'll include your code in my loop though files code..(so that the data can be retrived for all the files inside a folder)

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...