Author Topic: Utilizing existing polylines in a new polyline  (Read 1125 times)

0 Members and 1 Guest are viewing this topic.

wjbzone

  • Guest
Utilizing existing polylines in a new polyline
« 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

CAB

  • Global Moderator
  • Seagull
  • Posts: 10369
Re: Utilizing existing polylines in a new polyline
« Reply #1 on: December 22, 2007, 10:39:04 AM »
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?
I've reached the age where the happy hour is a nap. ()
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Crank

  • Swamp Rat
  • Posts: 1441
Re: Utilizing existing polylines in a new polyline
« Reply #2 on: December 28, 2007, 07:35:26 AM »
@wjbzone: I think you want something that's already available. Try the BPOLY or BOUNDARY command.

 Vault Professional 2018     /      Building Design Suite Ultimate 2017     /     AEC Collection 2018 + 2019 +2020

gile

  • Water Moccasin
  • Posts: 2233
  • Marseille, France
Re: Utilizing existing polylines in a new polyline
« Reply #3 on: December 28, 2007, 09:09:34 AM »
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.

Code: [Select]
;;; 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)
)
Speaking English as a French Frog

CAB

  • Global Moderator
  • Seagull
  • Posts: 10369
Re: Utilizing existing polylines in a new polyline
« Reply #4 on: December 28, 2007, 11:26:43 AM »
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?
I've reached the age where the happy hour is a nap. ()
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

gile

  • Water Moccasin
  • Posts: 2233
  • Marseille, France
Re: Utilizing existing polylines in a new polyline
« Reply #5 on: December 28, 2007, 01:17:15 PM »
Quote
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...
Speaking English as a French Frog

VovKa

  • Swamp Rat
  • Posts: 1173
  • Ukraine
Re: Utilizing existing polylines in a new polyline
« Reply #6 on: December 28, 2007, 03:00:57 PM »
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