BIGAL Posted July 3, 2023 Posted July 3, 2023 This can be used to find Gcen (setq pt (osnap (vlax-curve-getStartPoint obj) "gcen")) That should be enough to get you started. obj is a vl object. 1 Quote
masterfal Posted July 4, 2023 Posted July 4, 2023 hmm not 100% sure how to use that exactly unfortunately.. i found this code below which is starting to head in the direction i need. this one adds text to midpoint of any polygon. just gotta work out how i can tweak it so instead of adding text it can use that midpoint to move the object from. (defun c:POLYMID ( / ss) (if (setq ss (ssget '((0 . "LWPOLYLINE")))) (repeat (setq cnt (sslength ss)) (setq e (ssname ss (setq cnt (1- cnt)))) (if (not (zerop (getpropertyvalue e "Closed"))) (Text (GCen e) (* 0.05 (eHeight e)) "X" );text );if );repeat );if (prompt "\nTEST Complete.") (princ) );defun (defun Text (pt hgt str) (entmakex (list (cons 0 "TEXT") (cons 10 pt) (cons 11 pt) (cons 40 hgt) (cons 1 str) (cons 72 1) (cons 73 2))) ) (defun GCen (e / ) (command "_.DRAWORDER" e "" "_f") (osnap (vlax-curve-getstartpoint e) "gcen") ) (defun PolyPoints (e / return cnt) (repeat (setq cnt (fix (getpropertyvalue e "EndParam"))) (setq return (cons (list (getpropertyvalue e "Vertices" (setq cnt (1- cnt)) "Position/X") (getpropertyvalue e "Vertices" cnt "Position/Y")) return );cons );setq );repeat ) (defun corners (points) ; <-- compliments of dbroad (list (apply 'mapcar (cons 'min points)) (apply 'mapcar (cons 'max points))) ) (defun eHeight (e / cnr) (setq cnr (corners (PolyPoints e))) (- (cadadr cnr) (cadar cnr)) ) Quote
BIGAL Posted July 4, 2023 Posted July 4, 2023 Ok (setq ent (car (entsel "\nPick pline "))) (setq obj (vlax-ename->vla-object ent)) (setq pt (osnap (vlax-curve-getStartPoint obj) "gcen")) (command "move" ent "" pt) Quote
Recommended Posts
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.