yxl030 Posted September 17, 2021 Share Posted September 17, 2021 If the base point of block is not in the block,how to get the coordinates of it? As other people will use these diagrams, I can't change the base point. I wrote a lisp, but there are sometimes it's correct and sometimes it's not. (defun c:test() (setq BasePoint (list -34.80394906 16.72215194)) ;;the Offset coordinates from 0,0 (print "select the block1") ;; this is correct (setq ss (ssget '((0 . "INSERT")))) (repeat (setq i (sslength ss)) (setq px (cdr (assoc 10 (entget (ssname ss (setq i (1- i))))))) (setq blkAng (cdr (assoc 50 (entget (ssname ss i))))) (setq sx (cdr (assoc 41 (entget (ssname ss i))))) (setq sy (cdr (assoc 42 (entget (ssname ss i))))) (print sx) (print sy) (setq p0 (blkCo px blkAng BasePoint sx sy)) (command "line" p0 '(0 0) "") ) (setq BasePoint (list -628.69148552 795.40681600)) (print "select the block2") ;; this is not (setq ss (ssget '((0 . "INSERT")))) (repeat (setq i (sslength ss)) (setq px (cdr (assoc 10 (entget (ssname ss (setq i (1- i))))))) (setq blkAng (cdr (assoc 50 (entget (ssname ss i))))) (setq sx (cdr (assoc 41 (entget (ssname ss i))))) (setq sy (cdr (assoc 42 (entget (ssname ss i))))) (print sx) (print sy) (setq p0 (blkCo px blkAng BasePoint sx sy)) (command "line" p0 '(0 0) "") ) ) (defun blkCo(blkInsert blkAng BasePoint sx sy / p0 px py ) (setq px (* (car BasePoint) sx)) (setq py (* (cadr BasePoint) sy)) (setq p0x (- (car blkInsert) (- (* (cos blkAng) px) (* (sin blkAng) py)))) (setq p0y (- (cadr blkInsert) (+ (* (cos blkAng) py) (* (sin blkAng) px)))) (setq p0 (list p0x p0y)) ) And Is there a better way to do this? Drawing1.dwg Quote Link to comment Share on other sites More sharing options...
michael256 Posted September 17, 2021 Share Posted September 17, 2021 to set the block base point to 0,0 I would just open the block in the editor then select all, start move command, then select what you want the new base point to be and type 0,0. Quote Link to comment Share on other sites More sharing options...
zwonko Posted September 17, 2021 Share Posted September 17, 2021 Maybe this will be help for You: http://www.lee-mac.com/changeblockinsertion.html Quote Link to comment Share on other sites More sharing options...
yxl030 Posted September 18, 2021 Author Share Posted September 18, 2021 michael256, zwonko, thank you for your reply, Modifying blocks will affect other people. lee-mac 's lisp is great. I use it a lot Quote Link to comment Share on other sites More sharing options...
michael256 Posted September 18, 2021 Share Posted September 18, 2021 Sorry I obviously didn't read the question properly before replying Quote Link to comment Share on other sites More sharing options...
lrm Posted September 18, 2021 Share Posted September 18, 2021 I'm not sure exactly what you want to do but nentsel may be of help. (defun c:test2 () (princ "\nSelect the block") (setq blkdata (nentsel)) (setq Tmatrix (nth 2 blkdata)) (setq blk_pt (nth 3 Tmatrix)) (command "_point" blk_pt) (princ "\nBase point = ") (princ blk_pt) (setq ang (/ (* 180.0 (angle '(0 0 0) (nth 0 Tmatrix))) pi)) (princ "\nAngle = ") (princ ang) (setq xscale (distance '(0 0 0) (nth 0 Tmatrix))) (setq yscale (distance '(0 0 0) (nth 1 Tmatrix))) (princ "\nX scale = ") (princ xscale) (princ "\nY scale = ") (princ yscale) (princ) ) Quote Link to comment Share on other sites More sharing options...
yxl030 Posted September 26, 2021 Author Share Posted September 26, 2021 lrm,Thank you. Sorry for my late response. I later learned that the units of a block also affect position conversion Quote Link to comment Share on other sites More sharing options...
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.