TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: wjbzone on December 22, 2007, 09:12:05 AM
-
When drawing a new polyline, in order to use a portions of existing polylines, my options are:
1. Continue drawing the new polyline and snap to the endpoints on the existing polylines.
2. Copy the existing polylines, trim , and join to the new polyline.
Either option can be time consuming when there are a lot of existing polylines.
My main reason for doing this is to create closed polylines and get areas. When the areas are adjacent to each other the closed polylines are coincident over many points.
Any suggestions appreciated.
Bill
-
I don't get the picture yet of what problems you are having. Perhaps a sample DWG?
There are a lot of 'Pline Join' routines out there.
Are you simple wanting to select a pline & want to be able to CONTINUE drawing the pline?
You mentioned TRIM, where does that come into play?
-
@wjbzone: I think you want something that's already available. Try the BPOLY or BOUNDARY command.
-
Hi,
I'm not sure to understand what you need, but here's a routine which creates a new polyline on the boundary of adjoining closed polylines.
In the attached picture, selecting the white plines creates the green ones.
;;; MERGE -Gilles Chanteau- 01/01/06
;;; Creates a new closed pline on the boundary of each group of adjoining closed plines
(defun c:merge (/ err arcbulge Space ss lst reg Norm
expl objs regs olst blst plst dlst tlst blg
pline
)
(vl-load-com)
;;;***************************************************************;;;
(defun err (msg)
(if (= msg "Fonction annulée")
(princ)
(princ (strcat "\nErreur: " msg))
)
(vla-endundomark *acdoc*)
(setq *error* m:err
m:err nil
)
(princ)
)
;;;***************************************************************;;;
(defun arcbulge (arc)
(/ (sin (/ (vla-get-TotalAngle arc) 4))
(cos (/ (vla-get-TotalAngle arc) 4))
)
)
;;;***************************************************************;;;
(or *acdoc*
(setq *acdoc* (vla-get-activeDocument (vlax-get-acad-object)))
)
(setq Space (if (= 1 (getvar "CVPORT"))
(vla-get-PaperSpace *acdoc*)
(vla-get-Modelspace *acdoc*)
)
m:err *error*
*error* err
)
(prompt "\nSelect polylines to merge: ")
(if (setq ss (ssget '((0 . "LWPOLYLINE"))))
(progn
(vla-StartUndoMark *acdoc*)
(if (setq reg
(vlax-invoke
Space
'addRegion
(mapcar 'vlax-ename->vla-object
(vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
)
)
)
(progn
(while (cadr reg)
(vla-boolean
(car reg)
acUnion
(cadr reg)
)
(setq reg (cons (car reg) (cddr reg)))
)
(setq reg (car reg)
Norm (vlax-get reg 'Normal)
expl (vlax-invoke reg 'Explode)
)
(vla-delete reg)
(while expl
(setq objs (vl-remove-if-not
'(lambda (x)
(or
(= (vla-get-ObjectName x) "AcDbLine")
(= (vla-get-ObjectName x) "AcDbArc")
)
)
expl
)
regs (vl-remove-if-not
'(lambda (x) (= (vla-get-ObjectName x) "AcDbRegion"))
expl
)
)
(if objs
(progn
(setq olst (mapcar '(lambda (x)
(list x
(vlax-get x 'StartPoint)
(vlax-get x 'EndPoint)
)
)
objs
)
)
(while olst
(setq blst nil)
(if (= (vla-get-ObjectName (caar olst)) "AcDbArc")
(setq blst (list (cons 0 (arcbulge (caar olst)))))
)
(setq plst (cdar olst)
dlst (list (caar olst))
olst (cdr olst)
)
(while
(setq
tlst (vl-member-if
'(lambda (x)
(or (equal (last plst) (cadr x) 1e-9)
(equal (last plst) (caddr x) 1e-9)
)
)
olst
)
)
(if (equal (last plst) (caddar tlst) 1e-9)
(setq blg -1)
(setq blg 1)
)
(if (= (vla-get-ObjectName (caar tlst)) "AcDbArc")
(setq
blst (cons (cons (1- (length plst))
(* blg (arcbulge (caar tlst)))
)
blst
)
)
)
(setq plst (append plst
(if (minusp blg)
(list (cadar tlst))
(list (caddar tlst))
)
)
dlst (cons (caar tlst) dlst)
olst (vl-remove (car tlst) olst)
)
)
(setq pline
(vlax-invoke
Space
'addLightWeightPolyline
(apply 'append
(mapcar '(lambda (x)
(setq x (trans x 0 Norm))
(list (car x) (cadr x))
)
(reverse (cdr (reverse plst)))
)
)
)
)
(vla-put-Closed pline :vlax-true)
(mapcar
'(lambda (x) (vla-setBulge pline (car x) (cdr x)))
blst
)
(vla-put-Elevation
pline
(caddr (trans (car plst) 0 Norm))
)
(vla-put-Normal pline (vlax-3d-point Norm))
(mapcar 'vla-delete dlst)
)
)
)
(if regs
(progn
(setq
expl (append (vlax-invoke (car regs) 'Explode)
(cdr regs)
)
)
(vla-delete (car regs))
)
(setq expl nil)
)
)
)
)
(vla-EndUndoMark *acdoc*)
)
)
(setq *error* m:err
m:err nil
)
(princ)
)
-
gile,
In your bag of tricks do you have a routine that will allow the selections of objects and then will create
a pline outline of each closed area? And will it allow a fuzz factor for gaps?
-
gile,
In your bag of tricks do you have a routine that will allow the selections of objects and then will create
a pline outline of each closed area? And will it allow a fuzz factor for gaps?
No, I haven't...
-
a routine that will allow the selections of objects and then will create
a pline outline of each closed area? And will it allow a fuzz factor for gaps?
i know this may be of no help, but it will be easier to do this kind of trick with autocad map