Jump to content

to get center of the to the two circle and length-width of rectangle by single click.


Recommended Posts

Posted
Thank you sir, for your reply.

 

Yes sir, I have tried both "w" and "a". But, it's not working. In your program, it is not repeating the data, if we go for getting the data for circle only. But, the problem comes when, I tried to get both the polylines and circles, in two different csv files respectively. So, please help me something about it.

 

if the XY data repeating maybe due to solid hole has top & bottom, as i mentioned in post #12.

we must understand exploded solid may has many parts (regions / surfaces / polylines etc..) it may confusing. i'm not able to determine which part accurately.

 

if in plan view why not using bpoly ? just click in the hole you only get 1 polyline (boundary) then export the data csv?

  • Replies 26
  • Created
  • Last Reply

Top Posters In This Topic

  • hanhphuc

    10

  • magan

    7

  • sonali

    5

  • amili

    2

Top Posters In This Topic

Posted Images

Posted

No sir, I am not talking about XY data, I am OK with it as you have explained.

 

Let me be more clear about my problem.

 

Suppose I have a one drawing, in which I have loaded our lisp code. By our code, there will be two different csv files be generated for circles and polyline. I am OK till now.

 

But, Now if I again load it on the same drawing, then the previous result is shown alongwith the latest results. So unnecessary handling of garbage data is collected.

And, problem doesn't end here. Now, if I delete the file and then again load the code on the drawing then also it shows same garbage data. So, please help me remove those unnecessary previous data from my files.

Thank you.

Posted
No sir, I am not talking about XY data, I am OK with it as you have explained.

 

Let me be more clear about my problem.

 

Suppose I have a one drawing, in which I have loaded our lisp code. By our code, there will be two different csv files be generated for circles and polyline. I am OK till now.

 

But, Now if I again load it on the same drawing, then the previous result is shown alongwith the latest results. So unnecessary handling of garbage data is collected.

And, problem doesn't end here. Now, if I delete the file and then again load the code on the drawing then also it shows same garbage data. So, please help me remove those unnecessary previous data from my files.

Thank you.

 

The code in this thread only collecting circle with one file created.

if you have code for collecting polyline (or modified), you can post it here.

i suspect your code may be have some variables not localized?

(defun c:test ( / [color="green"]put variables here[/color])
...
...)

 

if that is your issue, here's good topic about localising Variables - Lee Mac -

Posted
This example is just start point

which to get circle coordinates from solid.

method as proposed by Mr.Alan (BIGAL) at post#2

 

update v1.1

additional export csv as requested by amili @post#15

7/02/15

(vl-load-com)
(defun c:test (/ i e p1 p2 ss lst q var[color="red"] f fn dat dat1[/color]) 
;hanhphuc 2014
 (set 'var (getvar 'cmdecho ))
 (setvar 'cmdecho 0) 
 (if (and (setq e (entsel "\nPlease select solid.. ")) (setq e (car e)) (= (cdr (assoc 0 (entget e))) "3DSOLID"))
   (progn (vla-GetBoundingBox (setq obj (vlax-ename->vla-object e)) 'p1 'p2)
   (mapcar ''((a b) (set a (vlax-safearray->list b))) '(p1 p2) (list p1 p2))
   (command "_explode" e)
   (setq i   0
	 ss  (ssget "C" p1 p2)
	 lst (mapcar '(lambda(x)
			(setq q nil)
			(if
			 (= (cdr (assoc 0 (entget x))) "REGION")
			 (setq q (cons (LM:reg x) q))
			 (setq q (cons (vlax-ename->vla-object x) q))
			 )
			(if
			 (listp q)
			 (LM:flatten q)
			 q
			 )
			)
		     (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
		     ) ;_ end of mapcar
	 ) ;_ end of setq
     
   (foreach o (vl-remove-if-not ''((x) (= (vla-get-ObjectName x) "AcDbCircle")) (LM:flatten lst))
     
     (setq dat(cons (princ (strcat [color="red"]"\nCIRCLE_"[/color] (itoa (setq i (1+ i))) [color="red"]" "[/color]
	     (vl-princ-to-string
		 (mapcar ''((x)(vlax-get o x)) '(Radius Center))
	       )))
		     dat))
       
     ) ;_ end of foreach

   (command "_.U")


[color="red"](setq fn (strcat (getvar "dwgprefix") "hole dat.csv") f (open fn "w"))
[color="blue"] ; If you don't want to override file ,to append use (open fn "a") as suggested by Marko @ post#14[/color]

(foreach $
(foreach x dat
 (setq	dat1 (cons (vl-string-translate
	     " "
	     ","
	     (vl-list->string
	       (vl-remove-if ''((a) (or (= a 10) (= a 40) (= a 41))) (vl-string->list x))
	       ) ;_ end of vl-list->string
	     ) ;_ end of vl-string-translate
	   dat1
	   ) ;_ end of cons
) ;_ end of setq
 ) ;_ end of foreach
(write-line $ f))
(write-line " " f)
(if f (close f))
(startapp "notepad" fn)[/color]     [color="blue"];<--remove this line if you don't want it to pop-up everytime[/color]
   ) ;_ end of progn
   ) ;_ end of if
 (setvar 'cmdecho var)
 (princ)
 ) ;_ end of defun

 

sub-functions credit to Lee Mac

;;;http://www.cadtutor.net/forum/showthread.php?35506-How-to-get-Region-coordinates/page2
;;;adopted as sub-function
(defun LM:reg (reg / RetObj)
 (setq Reg (vlax-ename->vla-object reg))
 (if (vlax-method-applicable-p reg 'explode)
 (progn
 (setq RetObj (vlax-safearray->list (vlax-variant-value (vla-explode Reg))))
 (repeat (length RetObj)
   (if	(eq "AcDbRegion" (vla-get-ObjectName (car RetObj)))
     (setq RetObj (append RetObj (vlax-safearray->list (vlax-variant-value (vla-explode (car RetObj))))))
     (setq RetObj (append RetObj (list (car RetObj))))
     ) ;_ end of if
   (setq RetObj (cdr RetObj))
   ) ;_ end of repeat
 )
   )
 retobj
 ) ;_ end of defun


;; Flatten List  -  Lee Mac
;; Transforms a nested list into a non-nested list
;; http://www.lee-mac.com/flatten.html

(defun LM:flatten ( l )
   (if (atom l)
       (list l)
       (append (LM:flatten (car l)) (if (cdr l) (LM:flatten (cdr l))))
   )
)

 

*The overlapped circles can be filtered using x,y coordinates (2D)

 

 

 

 

 

Hey, sir. I want your little bit guidance in my work. I am using this code, but, one thing that I want to is to explode the polyline to convert it into set of lines. The code that will be loaded is required to explode only polylines ot whole 3D solid. Can you help me to get this, by addition of some codes, here itself. I need your help sir. Thank you in advance.

Posted
Hey, sir. I want your little bit guidance in my work. I am using this code, but, one thing that I want to is to explode the polyline to convert it into set of lines. The code that will be loaded is required to explode only polylines ot whole 3D solid. Can you help me to get this, by addition of some codes, here itself. I need your help sir. Thank you in advance.

 

i'll try my best but not familiar solid object.

you may try to explode a solid object manually

with 1st step we normally can get the region etc

then repeat 2nd 3rd so on.. (exploding)

see what can you collect?

only arc , circle , line but not polyline :o

 

you can also study Lee Mac's function how it works :thumbsup:

  • 4 weeks later...
Posted
This example is just start point

which to get circle coordinates from solid.

method as proposed by Mr.Alan (BIGAL) at post#2

 

update v1.1

additional export csv as requested by amili @post#15

7/02/15

(vl-load-com)
(defun c:test (/ i e p1 p2 ss lst q var[color="red"] f fn dat dat1[/color]) 
;hanhphuc 2014
 (set 'var (getvar 'cmdecho ))
 (setvar 'cmdecho 0) 
 (if (and (setq e (entsel "\nPlease select solid.. ")) (setq e (car e)) (= (cdr (assoc 0 (entget e))) "3DSOLID"))
   (progn (vla-GetBoundingBox (setq obj (vlax-ename->vla-object e)) 'p1 'p2)
   (mapcar ''((a b) (set a (vlax-safearray->list b))) '(p1 p2) (list p1 p2))
   (command "_explode" e)
   (setq i   0
	 ss  (ssget "C" p1 p2)
	 lst (mapcar '(lambda(x)
			(setq q nil)
			(if
			 (= (cdr (assoc 0 (entget x))) "REGION")
			 (setq q (cons (LM:reg x) q))
			 (setq q (cons (vlax-ename->vla-object x) q))
			 )
			(if
			 (listp q)
			 (LM:flatten q)
			 q
			 )
			)
		     (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
		     ) ;_ end of mapcar
	 ) ;_ end of setq
     
   (foreach o (vl-remove-if-not ''((x) (= (vla-get-ObjectName x) "AcDbCircle")) (LM:flatten lst))
     
     (setq dat(cons (princ (strcat [color="red"]"\nCIRCLE_"[/color] (itoa (setq i (1+ i))) [color="red"]" "[/color]
	     (vl-princ-to-string
		 (mapcar ''((x)(vlax-get o x)) '(Radius Center))
	       )))
		     dat))
       
     ) ;_ end of foreach

   (command "_.U")


[color="red"](setq fn (strcat (getvar "dwgprefix") "hole dat.csv") f (open fn "w"))
[color="blue"] ; If you don't want to override file ,to append use (open fn "a") as suggested by Marko @ post#14[/color]

(foreach $
(foreach x dat
 (setq	dat1 (cons (vl-string-translate
	     " "
	     ","
	     (vl-list->string
	       (vl-remove-if ''((a) (or (= a 10) (= a 40) (= a 41))) (vl-string->list x))
	       ) ;_ end of vl-list->string
	     ) ;_ end of vl-string-translate
	   dat1
	   ) ;_ end of cons
) ;_ end of setq
 ) ;_ end of foreach
(write-line $ f))
(write-line " " f)
(if f (close f))
(startapp "notepad" fn)[/color]     [color="blue"];<--remove this line if you don't want it to pop-up everytime[/color]
   ) ;_ end of progn
   ) ;_ end of if
 (setvar 'cmdecho var)
 (princ)
 ) ;_ end of defun

 

sub-functions credit to Lee Mac

;;;http://www.cadtutor.net/forum/showthread.php?35506-How-to-get-Region-coordinates/page2
;;;adopted as sub-function
(defun LM:reg (reg / RetObj)
 (setq Reg (vlax-ename->vla-object reg))
 (if (vlax-method-applicable-p reg 'explode)
 (progn
 (setq RetObj (vlax-safearray->list (vlax-variant-value (vla-explode Reg))))
 (repeat (length RetObj)
   (if	(eq "AcDbRegion" (vla-get-ObjectName (car RetObj)))
     (setq RetObj (append RetObj (vlax-safearray->list (vlax-variant-value (vla-explode (car RetObj))))))
     (setq RetObj (append RetObj (list (car RetObj))))
     ) ;_ end of if
   (setq RetObj (cdr RetObj))
   ) ;_ end of repeat
 )
   )
 retobj
 ) ;_ end of defun


;; Flatten List  -  Lee Mac
;; Transforms a nested list into a non-nested list
;; http://www.lee-mac.com/flatten.html

(defun LM:flatten ( l )
   (if (atom l)
       (list l)
       (append (LM:flatten (car l)) (if (cdr l) (LM:flatten (cdr l))))
   )
)

 

*The overlapped circles can be filtered using x,y coordinates (2D)

 

 

 

 

Hello, sir. Again I am here in need of your guidance. Sir, the code that you have provided is for 3D solid. But, if it is just poyline, then what modifications, I have to do in this code,.? Please help me, sir in these regard. Thank you.

  • 6 months later...
Posted

hello

this thread is related to me, and my problem is same as amili's post(post 17).

i am changing in above coding as AcDBPOLYLINE instead of AcDBCIRCLE but not any coordinate desplay.

please help regarding this...

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