Juergen Posted February 13, 2019 Posted February 13, 2019 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 Quote
BIGAL Posted February 13, 2019 Posted February 13, 2019 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 Quote
Juergen Posted February 14, 2019 Author Posted February 14, 2019 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 Quote
BIGAL Posted February 15, 2019 Posted February 15, 2019 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. Quote
Juergen Posted February 18, 2019 Author Posted February 18, 2019 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. Quote
Tharwat Posted February 18, 2019 Posted February 18, 2019 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) ) Quote
dlanorh Posted February 18, 2019 Posted February 18, 2019 (edited) Beaten to it AGAIN 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 February 18, 2019 by dlanorh Updated lisp 1 Quote
Juergen Posted February 19, 2019 Author Posted February 19, 2019 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. Quote
Tharwat Posted February 19, 2019 Posted February 19, 2019 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. Quote
Juergen Posted February 19, 2019 Author Posted February 19, 2019 Thanks for this info. I already know that! Quote
Juergen Posted March 12, 2019 Author Posted March 12, 2019 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. Quote
BIGAL Posted March 14, 2019 Posted March 14, 2019 (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 March 14, 2019 by BIGAL Quote
Juergen Posted March 14, 2019 Author Posted March 14, 2019 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 Quote
BIGAL Posted March 14, 2019 Posted March 14, 2019 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")) Quote
Juergen Posted March 15, 2019 Author Posted March 15, 2019 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 Quote
BIGAL Posted March 15, 2019 Posted March 15, 2019 Something like this it was done 2103 I need to update. Text in polygon.lsp Quote
Juergen Posted March 18, 2019 Author Posted March 18, 2019 Hi Bigal I test your lsp. file. I become an Error: Bad string for ssget mode Quote
BIGAL Posted March 20, 2019 Posted March 20, 2019 (edited) 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 March 20, 2019 by BIGAL Quote
Recommended Posts
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.