Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Help for selecting multiple objects to export their coordinates and ID

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
koukouyuqi
2093 Views, 7 Replies

Help for selecting multiple objects to export their coordinates and ID

Hi Sirs

I am just starting learning lisp, And I am looking for a fast way to select multiple objects (usually circle) and export their coordinates and ID into a excel sheet through lisp programming.

As you might see in the attached drawing, the red circles are objects wanted. I have been trying to export their coordinates as well as their IDs in grids, e.g D28, Easting:  Northing:  . I still haven't found a good way to export ID for each circle.

As my code doesn't work, I wonder what's the most effective way to detect errors in lisp

Thx

Ji

 

 

Tags (2)
7 REPLIES 7
Message 2 of 8
hgasty1001
in reply to: koukouyuqi

Hi,

 

What do you mean by ID? circles have no ID as a property, may be you need the text inside, are they circles or blocks with attributes?.

 

The "attached drawing" it's not a drawing, just a pdf of no use for test.

 

Any way, if you are looking for the text inside circle here are some ideas and some code:

 

 

1.-Get a selection set with the circles (setq ss (ssget  '((0 . "CIRCLE")))

2.-Get the radious and center of each circle in the selection set

3.-Create a list of points for use in window polygon selection and filter for text for each circle:

 

 This will create the list of points to pass as a window polygon ("WP") option to ssget

(defun DiscretizeCircle(center radius n / ii delta px pxlist oldosmode)
  (setq ii 0)
  (setq delta (/ (* 2 pi) n))
  (while (< ii n)
    (setq px  (polar center (* delta ii) radius))
    (setq pxlist (cons px pxlist))
    (setq ii (+ ii 1))
  )
pxlist
)

 This will return the first text entity found, ignoring others inside the same circle (aprox)

(defun GetTxtInsideCircle(center radius / pxlist ss txt ret)
  (setq pxlist (DiscretizeCircle center radius 8))
  (setq pplist pxlist)
  (setq ss (ssget "wp" pxlist '((0 . "TEXT"))))
  (if ss
    (progn
      (setq txt (ssname ss 0))
      (setq ret (cdr (assoc 1 (entget txt))))
    )  
  ) 	
ret
)

 4.- Now you have the text, the radious and the center of each circle

 5.-Write this info to CSV file

 

 

 

 

Gaston Nunez

Message 3 of 8
dgorsman
in reply to: hgasty1001

Kelowna - beautiful small city.

 

To expand a bit more, use the Visual LISP editor to check for matching parenthesis, contextual hightlighting, and to step through the code one statement at a time.  All are useful for finding problems.

 

For the grid references of the circles, if they are not blocks with attributes you could generate a list of coordinates for each x- and y-series of defined grid values.  By checking the x/y coordinates against the two lists, you can reverse engineer the appropriate grid identifier.  If all the circles are supposed to be on-grid, you could also use this to filter out most other circles (provided everything is drawn accurately).

----------------------------------
If you are going to fly by the seat of your pants, expect friction burns.
"I don't know" is the beginning of knowledge, not the end.


Message 4 of 8
koukouyuqi
in reply to: dgorsman

thx a lot, it's really helpful
Message 5 of 8
koukouyuqi
in reply to: hgasty1001

Thx a lot
Message 6 of 8
Hallex
in reply to: koukouyuqi

Hi,

Try this code, pay attention to change circle layer name

and circle radius, I've marked those lines within the code

Say me how it will works for you

Cheers 🙂

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Message 7 of 8
macm.flais
in reply to: Hallex

Hi: Can i use this code to get the x, y and z coordinates of some circles in metric units? Thanks
Message 8 of 8
hmsilva
in reply to: macm.flais


@macm.flais wrote:
Hi: Can i use this code to get the x, y and z coordinates of some circles in metric units? Thanks

Hi macm.flais,

 

change

 (setq tmp (list (rtos (* rad 2) 3 3) (rtos (car cp) 3 3) (rtos (cadr cp) 3 3)))

 to

 (setq tmp (list (rtos (* rad 2) 2 3) (rtos (car cp) 2 3) (rtos (cadr cp) 2 3)))

 

Henrique

EESignature

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost