thajmul Posted January 16, 2023 Posted January 16, 2023 hii everyone, i want to make aligneddimension for block via loop function at the end much confusion. i have a collection of lists ((2 4 0) (4 4 0) (6 4 0)) for 3 block for example each iteration i want like given below list. p1=(2 4 0) p2 = (4 4 0) p1= (4 4 0) p2=(6 40) kindly give a solution on how to make it for multiple blocks.i sure this is wrong.i don't know how to use for vlax-3dpoint (defun c:best() (vl-load-com) (setq acadObj (vlax-get-acad-object)) (setq doc (vla-get-ActiveDocument acadObj)) (setq modelSpace (vla-get-ModelSpace doc)) (repeat (setq i (sslength ss_g)) (setq ss (vl-remove-if 'listp (mapcar 'cadr (ssnamex (setq i(ssget)))))) ;(setq ip (getbip ss)) ; (repeat (setq c (sslength i)) ;(setq p1 (vlax-3d-point (car ip)))i want use this method ;(setq p2 (vlax-3d-point (cadr ip))) ;(setq p3 1606.3613 598.032 0.0) ; (;setq dimObj (vla-AddDimAligned modelSpace p1 p2 p3)) (command "DimAligned" (setq p1 (car (car (getbip ss)))) (setq p2(car (car (cdr (getbip ss))))) (polar p1 (+ (angle p1 p2) 180.0) 800)) ) (defun getbip (ss) (mapcar '(lambda (x) (cdr (assoc 10 (entget x))) ) ss) ) Quote
BIGAL Posted January 16, 2023 Posted January 16, 2023 A few problems I would google "dim lines with lisp", the code is not really for a dimension pf blocks. Really saying need to start again, post a dwg with before and after then others will understand what you want. Quote
thajmul Posted January 16, 2023 Author Posted January 16, 2023 hi bigal, thanks for the reply. Kindly see the given code.I did it myself but it is not working for me. i want to insert loop method in this code but i don't know how to make.i hope you will understand everything.and attached drawing also. sorry for my english. (defun c:best() (vl-load-com) (setq acadObj (vlax-get-acad-object)) (setq doc (vla-get-ActiveDocument acadObj)) (setq modelSpace (vla-get-ModelSpace doc)) (setq ss (vl-remove-if 'listp (mapcar 'cadr (ssnamex (ssget))))) (setq ip (getbip ss)) ;here i got collection of list ;how to make loop here ;for example list coming ((2 4 0) (4 4 0) (6 4 0)) ;how to store list p1 p2 then second iteration p1 p2 (setq p1 (vlax-3d-point (car ip))) (setq p2 (vlax-3d-point (cadr ip))) (setq p3 (vlax-3d-point (car ip))) (setq dimObj (vla-AddDimAligned modelSpace p1 p2 p3)) ) (defun getbip (ss) (mapcar '(lambda (x) (cdr (assoc 10 (entget x))) ) ss) ) CHECKING2.dwg Quote
thajmul Posted January 18, 2023 Author Posted January 18, 2023 hii, i got finally that lisp that i wanted after i learned myself.i am very disappointed at the beginning. this lisp might useful for someone to make automatic dimensions for block alhamdulillah thanks to god. (defun c:adim(/ acadObj doc modelSpace ss ip n p1 p2 p3 dimObj ) (vl-load-com) (setq acadObj (vlax-get-acad-object)) (setq doc (vla-get-ActiveDocument acadObj)) (setq modelSpace (vla-get-ModelSpace doc)) (setq ss (vl-remove-if 'listp (mapcar 'cadr (ssnamex (setq i(ssget)))))) (setq ip (getbip ss)) (setq ip (vl-sort ip 'compare-points)) (setq n 0) (repeat (length ss) (setq p1 (vlax-3d-point(nth n ip))) (setq p2 (vlax-3d-point(nth (1+ n)ip))) (setq p3 (vlax-3d-point (polar (car ip)(+ (angle (car ip)(cadr ip))180.0)10))) (setq dimObj (vla-AddDimAligned modelSpace p1 p2 p3)) (setq n (1+ n)) ) ) (defun-q compare-points (a b / fuzz) (setq fuzz 1.0e-6) ;; comparison precision (if (equal (car a) (car b) fuzz) (if (equal (cadr a) (cadr b) fuzz) (> (caddr a) (caddr b)) (> (cadr a) (cadr b)) ) (> (car a) (car b)) ) ) (defun getbip (ss) (mapcar '(lambda (x) (cdr (assoc 10 (entget x))) ) ss) ) 1 Quote
mhupp Posted January 18, 2023 Posted January 18, 2023 (edited) 56 minutes ago, thajmul said: I got finally that lisp that i wanted after i learned myself. I find things learn yourself are hard to forget. tho here are some pointers. (defun c:adim (/ mspace ss blk pts p1 p2 p3 dim) (vl-load-com) (vla-startundomark (setq Drawing (vla-get-activedocument (vlax-get-acad-object)))) ;undo start point (setq mspace (vla-get-ModelSpace Drawing)) (if (setq ss (ssget '((0 . "INSERT")))) ;limit selection to blocks (foreach blk (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))) (setq pts (cons (cdr (assoc 10 (entget blk))) pts)) ) ) (setq pts ;sorts points (vl-sort pts '(lambda (a b) (if (equal (car a) (car b) 1e-6) (< (cadr a) (cadr b)) (< (car a) (car b)) ) ) ) ) (while (> (length pts) 1) ;loop if thier is more then one point left (setq p1 (car pts)) (setq p2 (cadr pts)) (setq MPT (mapcar '/ (mapcar '+ p1 p2) '(2 2 2))) midpoint between p1 & p2 (setq p3 (polar MPT (+ (angle p1 p2) (/ pi 2)) 10)) (setq dim (vla-AddDimAligned mspace p1 p2 p3)) (setq pts (cdr pts)) ;Returns a list containing all but the first element of the list ) (vla-EndUndoMark Drawing) (princ) ) Edited January 18, 2023 by mhupp 1 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.