Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Lisp for making a closed polyline a wipeout? Or another abstract 'mask'

9 REPLIES 9
Reply
Message 1 of 10
powermixx
5533 Views, 9 Replies

Lisp for making a closed polyline a wipeout? Or another abstract 'mask'

Is there a way to select a closed polygon and change it to a wipeout? Or can AutoCAD 'follow' (auto-trace) existing geometry and create an abstract shaped polygon? Thanks!
9 REPLIES 9
Message 2 of 10
Anonymous
in reply to: powermixx


Hi,

 

Try one of the following (use closed
polylines):

 

(vl-cmdf "_.wipeout" "_p" (car (entsel
"Select closed polyline: ")) "_y")

 

if you want to delete the original polyline,
or

 

(vl-cmdf "_.wipeout" "_p" (car (entsel
"Select closed polyline: ")) "_n")

 

if you want to keep it.

 

HTH


--
Humans are born with a wide horizon.
As time goes by, the
horizon narrows and
narrows, until it becomes a point of view.


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
Is
there a way to select a closed polygon and change it to a wipeout? Or can
AutoCAD 'follow' (auto-trace) existing geometry and create an abstract shaped
polygon? Thanks!
Message 3 of 10
_gile
in reply to: powermixx

Hi,

To create wipeouts from curve objects, you can try this.

{code};;; OB2WO -Gilles 'gile' Chanteau- 10/03/07
;;; Creates a "Wipeout" from an object (circle, ellipse, or polyline with arcs)
;;; Works whatever the current ucs and object OCS

(defun c:ob2wo (/ ent lst nor)
(vl-load-com)
(if (and (setq ent (car (entsel)))
(member (cdr (assoc 0 (entget ent)))
'("CIRCLE" "ELLIPSE" "LWPOLYLINE")
)
(setq lst (ent2ptlst ent))
(setq nor (cdr (assoc 210 (entget ent))))
)
(progn
(vla-StartundoMark
(vla-get-ActiveDocument (vlax-get-acad-object))
)
(makeWipeout lst nor)
(initget "Yes No")
(if
(= (getkword "\nDelete source object? [Yes/No] : ")
"Yes"
)
(entdel ent)
)
(vla-EndundoMark
(vla-get-ActiveDocument (vlax-get-acad-object))
)
)
)
)


;;; ENT2PTLST
;;; Returns the vertices list of the polygon figuring the curve object
;;; Coordinates defined in OCS

(defun ent2ptlst (ent / obj dist n lst p_lst prec)
(vl-load-com)
(if (= (type ent) 'ENAME)
(setq obj (vlax-ename->vla-object ent))
)
(cond
((member (cdr (assoc 0 (entget ent))) '("CIRCLE" "ELLIPSE"))
(setq dist (/ (vlax-curve-getDistAtParam
obj
(vlax-curve-getEndParam obj)
)
50
)
n 0
)
(repeat 50
(setq
lst
(cons
(trans
(vlax-curve-getPointAtDist obj (* dist (setq n (1+ n))))
0
(vlax-get obj 'Normal)
)
lst
)
)
)
)
(T
(setq p_lst (vl-remove-if-not
'(lambda (x)
(or (= (car x) 10)
(= (car x) 42)
)
)
(entget ent)
)
)
(while p_lst
(setq
lst
(cons
(append (cdr (assoc 10 p_lst))
(list (cdr (assoc 38 (entget ent))))
)
lst
)
)
(if (/= 0 (cdadr p_lst))
(progn
(setq prec (1+ (fix (* 25 (sqrt (abs (cdadr p_lst))))))
dist (/ (- (if (cdaddr p_lst)
(vlax-curve-getDistAtPoint
obj
(trans (cdaddr p_lst) ent 0)
)
(vlax-curve-getDistAtParam
obj
(vlax-curve-getEndParam obj)
)
)
(vlax-curve-getDistAtPoint
obj
(trans (cdar p_lst) ent 0)
)
)
prec
)
n 0
)
(repeat (1- prec)
(setq
lst (cons
(trans
(vlax-curve-getPointAtDist
obj
(+ (vlax-curve-getDistAtPoint
obj
(trans (cdar p_lst) ent 0)
)
(* dist (setq n (1+ n)))
)
)
0
ent
)
lst
)
)
)
)
)
(setq p_lst (cddr p_lst))
)
)
)
lst
)


;;; MakeWipeout creates a "wipeout" from a points list and the normal vector of the object

(defun MakeWipeout (pt_lst nor / dxf10 max_dist cen dxf_14)
(if (not (member "acwipeout.arx" (arx)))
(arxload "acwipeout.arx")
)
(setq dxf10 (list (apply 'min (mapcar 'car pt_lst))
(apply 'min (mapcar 'cadr pt_lst))
(caddar pt_lst)
)
)
(setq
max_dist
(float
(apply 'max
(mapcar '- (apply 'mapcar (cons 'max pt_lst)) dxf10)
)
)
)
(setq cen (mapcar '+ dxf10 (list (/ max_dist 2) (/ max_dist 2) 0.0)))
(setq
dxf14 (mapcar
'(lambda (p)
(mapcar '/
(mapcar '- p cen)
(list max_dist (- max_dist) 1.0)
)
)
pt_lst
)
)
(setq dxf14 (reverse (cons (car dxf14) (reverse dxf14))))
(entmake (append (list '(0 . "WIPEOUT")
'(100 . "AcDbEntity")
'(100 . "AcDbWipeout")
'(90 . 0)
(cons 10 (trans dxf10 nor 0))
(cons 11 (trans (list max_dist 0.0 0.0) nor 0))
(cons 12 (trans (list 0.0 max_dist 0.0) nor 0))
'(13 1.0 1.0 0.0)
'(70 . 7)
'(280 . 1)
'(71 . 2)
(cons 91 (length dxf14))
)
(mapcar '(lambda (p) (cons 14 p)) dxf14)
)
)
){code}


Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 4 of 10
powermixx
in reply to: powermixx

WOW! This is exactly what I was looking for! High powered stuff!!! Woohoo! Much thanks!
Message 5 of 10
Gouhar_Nayab
in reply to: Anonymous

Thank you very much

 

Cool stuff,

 

Gouhar Nayab

Message 6 of 10
Gouhar_Nayab
in reply to: _gile

Hi, AutoCAD 2015 Command: OB2WO Select object: ; error: no function definition: VLAX-ENAME->VLA-OBJECT Command: Plaese help Gouhar
Message 7 of 10
Shneuph
in reply to: Gouhar_Nayab

vlax-ename... help

 

You may need to load the vl functions using (vl-load-com)

It needs to be loaded anytime you want to use visualLISP functions.

It is only loaded in the current drawing (I think) So, you should either add it to acaddoc.lsp or to the beginning of any lisp file that uses visualLISP

 

BTW.. I've been using hatches as wipeouts for a long time and I think it's more useful and easier than wipeouts.  It also avoids problems that wipeouts sometimes can cause when plotting to PDF.  My drawings are set up to use Style Dependent Plot styles (.STB) instead of Color Dependant (.CTB).  Then I have a plot style that plots 0% screened (i.e. no line density) and 00 lineweight or 0 width lines.  Then I have a a G-WIPE layer using that plotstyle.  Then anything on that layer acts as a wipeout (Polylines w/ width, hatches etc.).  Give it a try if you can.

Message 8 of 10
Gouhar_Nayab
in reply to: Shneuph

Thank you very much for your reply. It is helpful. As far as this routine is concerned I basically use it for blocks........frequently. it save a lot of time by sparing me from trimming lines and because I belong to Architecture, frequent design changes and options are quite normal. Thank you very much again Gouhar
Message 9 of 10
marko_ribar
in reply to: Gouhar_Nayab

Gouhar, here you have very useful routine for making double hatches that imitate WIPEOUTs... You can use it on any closed shape like ordinary hatch... Only thing you have to do is to turn off or freeze layer HATCH-WIPEOUT when you are in paper space (assuming that you have set Paperspace background color to white)... Everything else is set... Hatch that is to be ploted has color 255,255,255 so it behaves just like ordinary WIPEOUT, and another masking hatch that comes over one that is plottable is on layer HATCH-WIPEOUT and has color of Model Space background, so it's basically the same as ordinary WIPEOUT... I even made this work with reactors, but I think it's much safer that you manually turn that maksing layer off...

 

Here is basic routine I use and have it in my Startup Suite...

http://www.cadtutor.net/forum/showthread.php?85448-Convert-DONUT-to-wipeout-DONUT&p=#3

 

And here is one with reactor, but be careful if you use this version (CAD is very unstable when it comes to reactors and may crash...) And make sure that once you loaded reactor, and you don't need it any more you decativate it with (vlr-remove *reactor variable*) or if you have more reactors you decativae them all with (vlr-remove-all)... As you know twicely loading the same reactor may cause unpredicatable behaviour of ACAD...

http://www.theswamp.org/index.php?topic=46658.msg516705#msg516705

 

M.R.

Marko Ribar, d.i.a. (graduated engineer of architecture)
Message 10 of 10
anderson51
in reply to: _gile

I am getting this error when trying to use the lisp routine

 

"error: no function definition: ENT2PTLST

 

Any idea why?

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost