Jump to content

Move object from mid between two points to mid between two points


Recommended Posts

Posted

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.

  • Like 1
Posted

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

 

Posted

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)

 

Posted

thats perfect. cheers mate, appreciate it!

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