Jump to content
Juergen

Coordinates from rectangles and circles inside

Recommended Posts

Juergen

Hi everybody!
I have a lisp that write the coordinates from
the rectangles into a .csv file.

 

What I need additionally is, the coordinates
into .csv from rectangles and the circles inside them as group.

 

Thank you for your help.

Example.dwg

Share this post


Link to post
Share on other sites
BIGAL

One of the options for SSGET is WP within polygon so you can use the pline co-ords and it will find all the objects inside.

 


(setq ss (ssget "WP" coordsxy (list (cons 0 "Circle")))) ; selection set of text within polygon

Share this post


Link to post
Share on other sites
Juergen

Hi Bigal,

 

is it possible that I select
all rectangles to get out
the coords from rectangles and the
circles within as .csv file eg.
from attachment?

(sorted from top left to bottom right)

Example.csv

Share this post


Link to post
Share on other sites
BIGAL

You can do as many rectangs as you like use a repeat to use each one though with a ssget WP repeated every time for each individual rectang. The wp only allows one set of co-ords.

Share this post


Link to post
Share on other sites
Juergen

Hi Bigal,

I use the l-coor.LSP

I have no idea how I can implement your suggestions.
Each rectangle should form a group with the circles in it.

Share this post


Link to post
Share on other sites
Tharwat

Hi,

Something like this?

(defun c:Test ( / int sel ent pts crd inc ins cir lst csv opn lwp)
  ;;----------------------------;;
  ;;	Tharwat - 18.Feb.2019	;;
  ;;----------------------------;;
  (and (princ "\nSelct visible rectangles :")
       (setq int -1 sel (ssget '((0 . "LWPOLYLINE"))))
       (while (setq ent (ssname sel (setq int (1+ int))))
         (setq pts nil crd nil)
         (and (setq pts (mapcar 'cdr (vl-remove-if-not '(lambda (p) (= (car p) 10)) (entget ent))))
              (setq inc -1 ins (ssget "_WP" pts '((0 . "CIRCLE"))))
              (while (setq cir (ssname ins (setq inc (1+ inc))))
                (setq crd (cons (cdr (assoc 10 (entget cir))) crd))
                )
              (setq lst (cons (list pts crd) lst))
              )
         )
       (setq csv (getfiled "Save csv file" "" "csv" 1))
       (setq num 0 opn (open csv "w"))
       (mapcar '(lambda (grp) (setq lwp t)
                  (mapcar '(lambda (l)
                             (if lwp (progn (write-line (strcat "LWpolyline (" (itoa (setq num (1+ num))) ")") opn) (setq lwp nil))
                               (mapcar '(lambda (str) (write-line str opn)) '("" "Circles"))
                               )
                             (mapcar '(lambda (pt)
                                        (write-line (strcat (rtos (car pt) 2) " " (rtos (cadr pt) 2)) opn))
                                     l
                                     )
                             )
                          grp
                          )
                  (write-line "" opn)
                  )
               lst
               )
       (close opn)
       )
  (princ)
  )

 

Share this post


Link to post
Share on other sites
dlanorh

Beaten to it AGAIN  :shock::P

 

The attached lisp will report the rectangles from top left to bottom right, and the circles within the rectangles from top left to bottom right.

 

I have also attached a CSV file produced by the lisp and a formatted XLSX file of the imported CSV file.

 

 

 

Example1.csv

Example1.xlsx

polyreport1.lsp

Edited by dlanorh
Updated lisp

Share this post


Link to post
Share on other sites
Juergen

Hi Tharwat, hi dlanorh!

 

You are great! That's exactly what I need.
You guys helped me a lot.
Excel does the rest for me 😀.
Thanks for your help and support.

Share this post


Link to post
Share on other sites
Tharwat

You'e welcome.

Be sure to have the selected LWpolylines visible in the screen since the function ssget with string mode "WP" would not recognize the objects outside the screen visible limits.

Share this post


Link to post
Share on other sites
Juergen

Thanks for this info.
I already know that!

Share this post


Link to post
Share on other sites
Juergen

Hi again,
sometimes there is a text with numbering in the ractangle.

Is it possible to add a text output in the lisp programm from Tharwat?

 

 

Thank you.

Share this post


Link to post
Share on other sites
BIGAL
Posted (edited)

This time its add text the next user will be add blocks. It may be easier to do a repeated defun that gets passed the object type when doing the,

 

(ssget "_WP" pts '((0 . "CIRCLE"))))
now
(ssget "_WP" pts '((0 . objecttype"))))

 

A cond would them make a decision run the correct defun  but each object type requires a different approach as they have different properties.

Circle center radius

Line end start

Text insert angle value

and so on.

 

Lastly Dataextraction comes to mind has all those sort of options and search filter and output can be saved.

 

A quick one part of a library answer for a circle using VL or use Tharwat ent/assoc method.


(defun circprop ( ent / obj lay cen rad lst ans)
(setq lst '())
(setq obj (vlax-ename->vla-object ent))
(setq lay (vla-get-layer obj))
(setq cen (vlax-safearray->list (vlax-variant-value (vla-get-center obj))))
(setq rad (vla-get-radius obj))
(setq ans (list lay cen rad))
)

 

Command: (setq AHcirc (circprop (car (entsel))))
Select object: ("DEFAULT" (363.156 299.783 0.0) 39.4607)
 

 

Edited by BIGAL

Share this post


Link to post
Share on other sites
Juergen

Hi Bigal,

 

what I mean is, that I need the coords from the rectangle and circles.

The text inside the recangle should write out only the text-line.

example.xlsx

Share this post


Link to post
Share on other sites
BIGAL

I understand but what I was getting at you need to look at what each object is inside the pline and make a choice about what you keep you could do a "circle,text" with ssget but you still have to treat them as different objects checking (assoc 0 is it a circle or text.

 


'((0 . "CIRCLE,Text"))
	

Share this post


Link to post
Share on other sites
Juergen

Hi Bigal,

i found the lisp "TextCoords" that export the text with the x,y coordinates.

Is it possible to join it with the code from Tharwat?

Or should i make my procedure with two steps?

TextCoords.LSP

Share this post


Link to post
Share on other sites
BIGAL

Something like this it was done 2103 I need to update.

 

 

Text in polygon.lsp

Share this post


Link to post
Share on other sites
Juergen

Hi Bigal

 

I test your lsp. file. I become an

Error: Bad string for ssget mode

Share this post


Link to post
Share on other sites
BIGAL

As I said something like this its hard coded for output file location, you need to just pull out the few lines that do the ssget "WP" I just used it and it worked on your sample dwg after I added some text. Your requested program has 3 requirements pline co-ords text and circle centres. It needs to be purpose written.

Edited by BIGAL

Share this post


Link to post
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
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

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