Author Topic: polygon split  (Read 3362 times)

0 Members and 1 Guest are viewing this topic.

Fuccaro

  • Guest
polygon split
« on: May 03, 2004, 04:25:56 AM »
Hello my friends!
I try to improve a program I wrote some time ago. The SPIREX routine is posted somewhere in this Forum, but it works only on convex polygons. I can not change this, so I try to write a Lisp to split a non-convex polygon in convex ones. Can someone suggest the way to do it –explanations, pseudo cod, anything to help me start?

P.S.
The vla-split-this-polygon-in-convex-ones doesn’t work  :D

hendie

  • Guest
polygon split
« Reply #1 on: May 03, 2004, 05:27:06 AM »
fuccaro,
you might want to take a look at this thread[/u], in particular, Stig's post near the bottom. It may give you some ideas

Anonymous

  • Guest
polygon split
« Reply #2 on: May 03, 2004, 07:00:02 AM »
Hendie
I read that, it's ok if working with surfaces. But I prefere solids -and for that I need to split the shape in convex regions, process them one by one and finally union together the resulted solids.
Hendie, I like your attitude. Altimes you are between the firsts offering your help...

Fuccaro

  • Guest
polygon split
« Reply #3 on: May 03, 2004, 07:03:06 AM »
Sorry, I forgot to sign in. The previous message is mine :-)

SMadsen

  • Guest
polygon split
« Reply #4 on: May 03, 2004, 07:17:32 AM »
Fuccaro, guess I gotta examine your SPIREX routine a bit closer to see what you mean (I can't get it to work but that's probably my fault).

The reason you don't just extrude the object is that because you need to keep the object from rotating along the path?

If not, then I'd just extrude the thing. The one below works with OCR based objects such as lwplines and circles (not with WCS based objects like ellipses):

Code: [Select]
(defun unitVect (p1 p2)
  (mapcar (function (lambda (p) (/ p (distance p1 p2))))
          (mapcar '- p2 p1)
  )
)

(defun C:exTest (/ plist fpts ang ang1 ax entl h1 lent osm pln pt rad s z)
  (setq pln  (car (entsel "\n Select shape to extrude: "))
        ax   (getpoint " Point on the axis? ")
        rad  (getdist ax "Radius: ")
        ang1 (/ (* pi (getreal "\nRotation angle (degrees): ")) 180.0)
        h1   (getdist " Height: ")
        s    (max 5 (getint " Segments: "))
        ang1 (/ ang1 s)
        h1   (float (/ h1 s))
        z    (caddr ax)
        ang  0.0
        lent (entlast)
        osm  (getvar "OSMODE")
  )
  (setvar "OSMODE" 0)
  (command "3DPOLY")
  (repeat s
    (setq pt    (polar ax ang rad)
          plist (cons (setq pt (subst z (last pt) pt)) plist)
          z     (+ z h1)
          ang   (+ ang ang1))
    (if (< (length fpts) 2)(setq fpts (cons pt fpts)))
    (command pt)
  )
  (command "")
  (cond ((not (eq (entlast) lent))
         (setq lent (entlast)
               entl (entget pln)
         )
         (entmod (subst (cons 210 (unitVect (cadr fpts)(car fpts)))(assoc 210 entl) entl))
         (command ".EXTRUDE" pln "" "Path" lent)
         (entdel lent)
        )
  )
  (setvar "OSMODE" osm)
)

Fuccaro

  • Guest
polygon split
« Reply #5 on: May 03, 2004, 09:41:54 AM »
Thank you for your answer.
I will try your program tomorrow.
The Spirex program extrudes a shape and it twist it in the same time. The extrusion is along a line, not a free path. The new thing is that the result is a solid, not a surface. Sorry, if it doesn’t work for you. I must admit that is unpolished, no error trap and so on. But for sure you can make it work.