Jump to content
toxicsquall

Copy Everything inside an object

Recommended Posts

toxicsquall

I have a lisp that copies everything inside a circle, but I wish I can copy everything inside a closed polyline.

Can you help me editing this code?

:roll:

 

(defun c:det (/	osm blip ent alist cir1	pt1 raio1 cir2 pt2 raio2 fator
      ss pt)
(setq p1 (getpoint "\nSelecione o raio do círculo de ampliação:"))
(command "CIRCLE" p1 pause "")
(command "undo" "be")
(setq osm (getvar "osmode"))
(setq blip (getvar "blipmode"))
(setvar "blipmode" 0)
(setvar "osmode" 0)
(setvar "cmdecho" 1)
(while (not cir1)
(setq ent (car (entsel "\nSelecione o círuculo a ampliar: ")))
(if	
(and ent     
(setq alist 
(entget ent))     
(= (cdr (assoc 0 alist)) "CIRCLE")
)
(setq cir1  ent
    pt1	  
(cdr (assoc 10 alist))
    raio1 
(cdr (assoc 40 alist))
     )
   )
 )
 
(command "copy" cir1 "" pt1 pause)
(setq	cir2  (entlast)
alist (entget cir2)
pt2   (cdr (assoc 10 alist))
 )
(command "scale" cir2 "" pt2 pause)
(setvar "cmdecho" 0)
 (setq	alist (entget cir2)
raio2 (cdr (assoc 40 alist))
fator (/ raio2 raio1)
 )
 (command "copy"
   "cp"
   
(foreach pt (pt_circulo pt1 raio1 T)
     (command pt)
     ""
   )
   "r"
   cir1
   ""
   pt1
   pt1
 )
(setq ss (ssget "p"))
 (command "move" ss "" pt1 pt2)
 (command "scale" ss "" pt2 fator)

(repeat 2
   (command "trim"
     cir2
     ""
     "f"
     (foreach pt (pt_circulo pt2 raio2 nil)
       
(command pt)
       ""
     )
     ""
   )
 )
 (setvar "blipmode" blip)
 (setvar "osmode" osm)
 (setvar "cmdecho" 1)
 (command "undo" "e")
 (princ)
)
(defun pt_circulo (centro raio inscrito / ang ndiv delta pt resp)
(setq	ang   0
ndiv  36
delta (dtor (/ 360 ndiv))
 )
(if (not inscrito)
   (setq raio (* 1.0001 (/ raio (cos (/ delta 2.0)))))
 )
(repeat (1+ ndiv)
(setq ang (+ ang delta))
(setq pt (polar centro ang raio))
(setq resp (append resp (list pt)))
 )
)
(defun dtor (a)
 (* pi (/ a 180.00))
)

(princ)

Share this post


Link to post
Share on other sites
BIGAL

Try this its for text just change the ssget line

; get text with closed pline example
; By Alan H jan 2014
(defun getcoords (ent)
 (vlax-safearray->list
   (vlax-variant-value
     (vlax-get-property
   (vlax-ename->vla-object ent)
   "Coordinates"
     )
   )
 )
)

(defun co-ords2xy (/ xy)
; convert now to a list of xy as co-ords are x y x y x y if 3d x y z x y z
(setq numb (/ (length co-ords) 2))
(setq I 0)
(repeat numb
(setq xy (list (nth i co-ords)(nth (+ I 1) co-ords) ))
(setq co-ordsxy (cons xy co-ordsxy))
(setq I (+ I 2))
)
)
; program starts here
(setq plist (ssget (list (cons 0 "lwpolyline"))))
(setq numb (sslength plist))
(setq J 0)
(repeat numb
(setq co-ords (getcoords (ssname plist J)))
(co-ords2xy)
(setq ss (ssget "WP" co-ordsxy (list (cons 0 "*text")))) ; selection set of text within polygon
; (setq ss (ssget "WP" co-ordsxy )) ; selection set within polygon
(princ (sslength ss)) ; this is howmany texts etc 
(setq co-ordsxy nil)
(setq J (+ J 1))
(setq ss nil)
) ; end repeat

Share this post


Link to post
Share on other sites
toxicsquall

It isn't working...

Share this post


Link to post
Share on other sites
Tharwat
but I wish I can copy everything inside a closed polyline.

Can you help me editing this code?

 

Hi,

 

Are you after selecting a closed polyline and highlight all objects that resides inside ?

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