+ Reply to Thread
Page 3 of 5 FirstFirst 1 2 3 4 5 LastLast
Results 21 to 30 of 48
  1. #21
    Junior Member
    Using
    AutoCAD 2010
    Join Date
    Mar 2013
    Posts
    23

    Default

    Registered forum members do not see this ad.

    Either an Excel file or .CSV file would be fine.

    Pline1 xy xy xy xy
    ITRP;
    33624;
    52;

    Ideally one column per line of text.

  2. #22
    Luminous Being
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    9,748

    Default

    This code works but found out a few things like if text is contained within 2 polygons it will find it twice. If I run it on your dwg it does not work, if I copy bits of your dwg then it works I am not sure what is causing error maybe something about blank polygons with no objects. Will try to find

    Code:
    (vl-load-com)
    (defun getcoords (ent)
      (vlax-safearray->list
        (vlax-variant-value
          (vlax-get-property
        (vlax-ename->vla-object ent)
        "Coordinates"
          )
        )
      )
    )
     
    (defun co-ords2xy ()
    ; convert now to a list of xy as co-ords are x y x y x y if 3d x y z x y z
    (setq numb (/ (length co-ords) 2))
    (setq I 0)
    (repeat numb
    (setq xy (list (nth I co-ords)(nth (+ I 1) co-ords) ))
    (setq coordsxy (cons xy coordsxy))
    (setq I (+ I 2))
    ) ; end repeat
    ) ; end defun
    ; program starts here
    (setq plobjs (ssget (list (cons 0 "lwpolyline"))))
    (setq numb1 (sslength plobjs))
    (setq x numb1)
    (repeat numb1
    (setq obj (ssname plobjs (setq x (- x 1))))
    (setq co-ords (getcoords obj))
    (co-ords2xy)
    ; write pline co-ords here
    (setq ss (ssget "WP" coordsxy (list (cons 0 "Text,Mtext")))) ; selection set of text within polygon
    (setq coordsxy nil) ; reset for next time
    (setq numb2 (sslength ss))
    (setq y numb2)
    (repeat numb2
    (setq anstext (vlax-get-property (vlax-ename->vla-object (ssname ss (setq y (- y 1)))) "Textstring"))
    (princ anstext) ; change to write text to file
    (princ "\n")
    ) ; end repeat2
    (setq ss nil) ; reset for next poly
    ) ; end repeat1
    (princ)
    Last edited by BIGAL; 10th Apr 2013 at 04:58 am.
    A man who never made mistakes never made anything

  3. #23
    Junior Member
    Using
    AutoCAD 2010
    Join Date
    Mar 2013
    Posts
    23

    Default

    Good work BigAl, Cheers.
    What is the command line text i should type in to run the programme?

  4. #24
    Luminous Being
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    9,748

    Default

    I have been trying to get it to work and found a few problems your polygons are doubled up and possibly overlapping line work and so does not work, if you just draw a closed pline put some text in will work. I have not finished it because it will not work properly with your drawing but any I make works perfect.

    Just save the code via Notepad call it say text in poly.lsp then appload "text in poly" it will ask for selection pick all on screen.

    Somebody out there ? any suggestion re his drawing ?
    A man who never made mistakes never made anything

  5. #25
    Junior Member
    Using
    AutoCAD 2010
    Join Date
    Mar 2013
    Posts
    23

    Default

    i keep getting this error when trying to load it:

    Getpoly.lsp successfully loaded.
    Command: ; error: syntax error
    Command:

  6. #26
    Luminous Being
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    9,748

    Default

    When you copied it into notepad did you copy all of it you must scroll down, I copied it from here and ran it works ok.
    A man who never made mistakes never made anything

  7. #27
    Junior Member
    Using
    AutoCAD 2010
    Join Date
    Mar 2013
    Posts
    23

    Default

    ahh yes, that now works in as much as i can select multiple polylines. i recive this error instead whether i select items from the existing drawing or from a new drawing:

    Select objects:
    ; error: no function definition: VLAX-ENAME->VLA-OBJECT
    Command:


    Did you manage to successfully output the information into an excel spreadsheet?

  8. #28
    Luminous Being
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    9,748

    Default

    Hi Drafty

    First add (VL-load-com) as first line of code, second I stopped because I could not get it to work with your drawing, I need help anyone out there ? something about your drawing.

    As a test just draw a few closed plines add some text and mtext you should see result on screen press F2. this is what would be output plus co ordinates.
    A man who never made mistakes never made anything

  9. #29
    Junior Member
    Using
    AutoCAD 2010
    Join Date
    Mar 2013
    Posts
    23

    Default

    It appears not to work in my drawing as you have confirmed. I then created a new drawing with some MTEXT and got this result in the command line:

    Select objects:
    test\P123\P56\Pgreen


    Where are the coordinates though?

    I will have a play round with my drawing some more to see if i can ascertain the issue.

    Thanks for your persistance with this :-)

  10. #30
    Luminous Being
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    9,748

    Default

    Registered forum members do not see this ad.

    As I implied I didn't finish it the x y variables are in 2 places co-ords & co-ordsxy just two different ways of making a list of the co-ords. I was just going to write out co-ords as excel will read it as space delimited.

    Code:
    old (setq co-ords (getcoords obj))
     
    new (setq co-ords (getcoords obj))
    (princ co-ords)
    A man who never made mistakes never made anything

Similar Threads

  1. Extracting xyz coordinates from 3d polylines
    By 1ridgey in forum AutoCAD Beginners' Area
    Replies: 2
    Last Post: 13th Apr 2012, 02:08 am
  2. How to do this handle????
    By stevep80 in forum AutoCAD 3D Modelling & Rendering
    Replies: 8
    Last Post: 3rd Jan 2012, 08:08 pm
  3. extracting cursor coordinates
    By rusty in forum AutoCAD Drawing Management & Output
    Replies: 4
    Last Post: 29th Jun 2006, 10:30 am

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts