Convert circled survey figure to polyline or normall circle

Convert circled survey figure to polyline or normall circle

lzedCB
Advocate Advocate
2,643 Views
12 Replies
Message 1 of 13

Convert circled survey figure to polyline or normall circle

lzedCB
Advocate
Advocate

Hello folks, anyone has some LISP to convert Survey Figure with circular shape to normall circle, preserving its shape and placing the new circle at elevation "0"? 

 

20240305-01-VÍDEO.gif

 Thanks!

 

 

 

 

0 Likes
Accepted solutions (3)
2,644 Views
12 Replies
Replies (12)
Message 2 of 13

ВeekeeCZ
Consultant
Consultant
Accepted solution

You should have posted a dwg. 

Also, there is a dedicated C3D Customization forum over HERE . 

 

(vl-load-com)

(defun c:SFCircle ( / s i p)
  
  (if (setq s (ssget))
    (repeat (setq i (sslength s))
      (setq p (vlax-invoke (vlax-ename->vla-object (ssname s (setq i (1- i)))) 'getpoints))
      (command "_.circle" "_3p"
	       "_non" (list (nth 0 p) (nth 1 p) 0.)
	       "_non" (list (nth 3 p) (nth 4 p) 0.)
	       "_non" (list (nth 6 p) (nth 7 p) 0.))))
  (princ)
  )

 

0 Likes
Message 3 of 13

Kent1Cooper
Consultant
Consultant

If the "Survey Figure" is a Polyline, or perhaps can be Exploded into one, I have a routine to convert a circular Polyline into a Circle -- CirclePolylineSwap.lsp, >here<.  It has commands to go both ways -- use P2C for this.  If that otherwise does what you want, the elevation=0 part is easily added.

EDIT:  But I agree that a sample drawing would be useful.  We can't see your command line or properties in the video, so [for those of us who don't know what a "Survey Figure" is, at least] we don't know what you're working with.  And what is the significance of their becoming a not-quite-regular hexagon and pentagon, rather than a Circle as requested?

Kent Cooper, AIA
0 Likes
Message 4 of 13

komondormrex
Mentor
Mentor

hey there,

survey figure - what is it?

0 Likes
Message 5 of 13

lzedCB
Advocate
Advocate

@ВeekeeCZ Hello! Thanks for this one. Is it possible to add a step to delete the selected Circle Figures and to place the created circle in Survey's Figure layer instead putting it in layer "0"? Thanks a LOT.

0 Likes
Message 6 of 13

ВeekeeCZ
Consultant
Consultant

Use at your own risk. I know nothing about those objects, if there are some dependencies the plain removal might cause trouble.

 

(vl-load-com)

(defun c:SFCircle ( / s i p o)
  
  (if (setq s (ssget))
    (repeat (setq i (sslength s))
      (setq o (vlax-ename->vla-object (ssname s (setq i (1- i)))))
      (setq p (vlax-invoke o 'getpoints))
      (setvar 'cmdecho 0)
      (command "_.circle" "_3p"
	       "_non" (list (nth 0 p) (nth 1 p) 0.)
	       "_non" (list (nth 3 p) (nth 4 p) 0.)
	       "_non" (list (nth 6 p) (nth 7 p) 0.))
      (setvar 'cmdecho 1)
      (vla-put-layer (vlax-ename->vla-object (entlast)) (vla-get-layer o))
      (vla-erase o)))
  (princ)
  )

 

0 Likes
Message 7 of 13

lzedCB
Advocate
Advocate

Hello, thanks for your new code. It almost did it:

 

20240308-01-VÍDEO.gif

 

It's just converting one of those to circles and seems to be getting an "error" in the end! Thanks!

 

0 Likes
Message 8 of 13

ВeekeeCZ
Consultant
Consultant

Man, again, and for the very last time, post a drawing!

0 Likes
Message 9 of 13

lzedCB
Advocate
Advocate

Sorry for missing this message! Here it goes an example file.

0 Likes
Message 10 of 13

ВeekeeCZ
Consultant
Consultant
Accepted solution

Ok, try this one.

 

(vl-load-com)

(defun c:SFCircle ( / s i p o e x p1 p2 p3)

  (setq x (ssadd))
  (if (setq s (ssget '((0 . "AECC_SVFIGURE"))))
    (repeat (setq i (sslength s))
      (setq e (ssname s (setq i (1- i))))
      (setq o (vlax-ename->vla-object e))
      (setq p (vlax-invoke o 'getpoints))
      (if (and (>= (length p) 9)
	       (setq p1 (list (nth 0 p) (nth 1 p) 0.))
	       (setq p2 (list (nth 3 p) (nth 4 p) 0.))
	       (setq p3 (list (nth 6 p) (nth 7 p) 0.))
	       (not (equal p1 p2 1e-6))
	       (not (equal p1 p3 1e-6))
	       (not (equal p2 p3 1e-6))
	       )
	(progn
	  (setvar 'cmdecho 0)
	  (command "_.circle" "_3p" "_non" p1 "_non" p2 "_non" p3)
	  (setvar 'cmdecho 1)
	  (vla-put-layer (vlax-ename->vla-object (entlast)) (vla-get-layer o))
	  (vla-erase o))
	(ssadd e x))))
  (if (> (sslength x) 0)
    (progn
      (princ (strcat "\n" (itoa (sslength x)) " objects unprocessed."))
      (sssetfirst nil x)))
  (princ)
  )

 

0 Likes
Message 11 of 13

lzedCB
Advocate
Advocate
Accepted solution

I guess nothing happened with the new code:

20240311-01-VÍDEO.gif

 

0 Likes
Message 12 of 13

ВeekeeCZ
Consultant
Consultant

Try the update. 

0 Likes
Message 13 of 13

lzedCB
Advocate
Advocate

Almost perfect @ВeekeeCZ . Seems that it only missed one conversion:

 

20240311-01-VÍDEO.gif

This is more than enough and I can fix it manually! Thanks a LOT.

0 Likes