Jump to content

Modify First Vertex of multi areas (polygons) to vertex more to north


Recommended Posts

Posted

I had one than, must selcted one by one and choose the vertex, (attach)

I ´ll like to modify to auto (all area in the drawn) alter first vertex on each polygon to vertex more to north.C2V Choose First vertex.lsp

 

thx felas

Posted

Can you better explain wat must happen?

Maybe upload a dwg example?

  • Like 1
Posted

Looks likes easy, but when you have 7000 polygons to do it, the hand Begin shake, kkk 

Posted (edited)

Oh, I see now.

 

There's a function that replaces the list of coordinates

(vlax-put (vlax-ename->vla-object ent) 'coordinates coords)

 

So I read the coordinates, set the most North one to 0, then replace the coordinates.

 

Like this:

Command MFV for Modify First Vertex

 

(vl-load-com)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; LW Vertices  -  Lee Mac
;; Returns a list of lists in which each sublist describes
;; the position, starting width, ending width and bulge of the
;; vertex of a supplied LWPolyline
(defun LM:LWVertices ( e )
    (if (setq e (member (assoc 10 e) e))
        (cons
            (list
                (assoc 10 e)
                (assoc 40 e)
                (assoc 41 e)
                (assoc 42 e)
            )
            (LM:LWVertices (cdr e))
        )
    )
)
  
(defun getVertices ( pline / verts vert res)
	(setq verts (LM:LWVertices (entget pline) ))
	(setq res (list))
	(foreach vert verts
		(setq p (cdr (assoc 10 vert)))
		(setq res (append res (list p)))
	)
	res
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; returns the index of the vertex with the max Y value
(defun getMaxYVert ( verts / maxY i ind)
	(setq maxY nil)
	(setq ind 0)
	(setq i 0)
	(foreach a verts
		(if (= nil maxY)
			(setq maxY (nth 1 a))
			(if (> (nth 1 a) maxY)
				(progn
					(setq ind i)
					(setq maxY (nth 1 a))
				)
			)
		)
		(setq i (+ i 1))
	)
	ind
)	

;; MFV for Modify First Vertex
(defun c:MFV ( / ss i j ent verts maxYindex verts2 coords)
	(setq ss (ssget (list (cons 0 "*POLYLINE") (cons 70 1))))
	(setq i 0)
	(repeat (sslength ss)
		;;(princ "\n")
		(setq ent (ssname ss i))
		(setq verts (getVertices ent))
		(setq maxYindex (getMaxYVert verts))
		(setq coords (list))		;; new list of coordinates. (list x0 y0 x1 y1 x2 y2...), rearraned to have the most North one first
		(setq j 0)
		(princ maxYindex)
		(repeat (length verts)
			(setq coords (append coords (list
				(nth 0 (nth (rem (+ j maxYindex) (length verts)) verts))
				(nth 1 (nth (rem (+ j maxYindex) (length verts)) verts))
			)))
		
			(setq j (+ j 1))
		)
		;; now replace the verices verts by coords
		(vlax-put (vlax-ename->vla-object ent) 'coordinates coords)
		;;(princ coords)
		(setq i (+ i 1))
	)
	(princ)
)

 

Edited by Emmanuel Delay
  • Like 1
Posted

Absolutely fantastic    👏👏👏👏👏👏👏👏👏👏👏

thanks a lot

  • Like 1

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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

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