mhy3sx Posted Sunday at 02:29 PM Posted Sunday at 02:29 PM (edited) I am searching for a lisp code to recognizes and dimensions LINE or ARC objects located in the Wall-2D layers and blocks in the CLOSETS-2D layer. like the image The dimension layer is DIM The idea is to pick 2 points like a line and automatic insert the dmensions. I use ZWCAD. Thanks Edited Sunday at 03:04 PM by mhy3sx Quote
BIGAL Posted Sunday at 10:32 PM Posted Sunday at 10:32 PM Yes I have something done like 40 years ago, but did you try QDIM is that in ZWCAD ? Quote
mhy3sx Posted yesterday at 09:12 AM Author Posted yesterday at 09:12 AM (edited) Hi BIGAL, I have try QDIM but working as Quote Select geometry to dimension : The QDIM don't dimension the block (look the image) I want to draw a line by specifying two points, to indicate where dimensions should be placed. This line should only appear on the layers named WALLS-2D and CLOSETS-2D. The WALLS-2D layer contains both lines and polylines, while the CLOSETS-2D layer contains blocks. Thanks Edited yesterday at 09:15 AM by mhy3sx Quote
mhupp Posted yesterday at 01:55 PM Posted yesterday at 01:55 PM Drawing the line would also pick up 4 lines across the block. would maybe have to do a fence ssget. and if block draw a bounding box to pick up lines but even then could be inaccurate if not a square. 1 Quote
mhy3sx Posted 18 hours ago Author Posted 18 hours ago I find a solution. I craete a polyline ,then auto dimension the polyline and delete the polyline. Beter tahn nothing Thanks 1 Quote
BIGAL Posted 15 hours ago Posted 15 hours ago (edited) As suggested by @mhupp if you use a fence option you can find objects and get their intersection points do a sort based on start point. For the block would do a Bounding Box around the block. and get the left and right edge points, then do the dims. Yes just need a line from left to right for "intersectwith". You can set the correct layers when doing the SSGET "F". If get time will dummy up your dwg and see what the code I have does. Edited 15 hours ago by BIGAL Quote
mhupp Posted 10 hours ago Posted 10 hours ago (edited) A lot shorter then i thought. will only work on horizontal polyline. adj p3 list to affect the offset. ;;----------------------------------------------------------------------;; ;; Poly DIM acts like QDIM but allows user to select horizontal points. ;; https://www.cadtutor.net/forum/topic/99059-auto-dimension-lisp/ (defun c:PLDIM (/ ent pts p1 p2 p3 ang) (vl-load-com) (command "_.pline") (while (= 1 (getvar "cmdactive")) (command pause) ) (setq ent (entlast)) (setq pts (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget ent)))) (while (cadr pts) (setq p1 (car pts) p2 (cadr pts) mid (mapcar '/ (mapcar '+ p1 p2) '(2 2 2)) p3 (mapcar '+ mid '(0.0 2.0 0.0)) ;adj 2.0 for offset. ) (command "_.DIMLINEAR" p1 p2 p3) (setq pts (cdr pts)) ) (entdel ent) (princ) ) Edited 2 hours ago by mhupp 1 Quote
Steven P Posted 1 hour ago Posted 1 hour ago (edited) A slight variation on MHUPPS (defun c:ADIM (/ pt1 pt2 MyLine MySS acount MyIntersect MyDistance MyDistances pta ptb) (defun LM:intersections ( ob1 ob2 mod / lst rtn ) ;; See Lee Mac website. Get intersection list (if (and (vlax-method-applicable-p ob1 'intersectwith) (vlax-method-applicable-p ob2 'intersectwith) (setq lst (vlax-invoke ob1 'intersectwith ob2 mod)) ) (repeat (/ (length lst) 3) (setq rtn (cons (list (car lst) (cadr lst) (caddr lst)) rtn) lst (cdddr lst) ) ) ) (reverse rtn) ) (command "line" (setq pt1 (getpoint)) pause "") ; Draw reference line. Mod to polyline possible (setq MyLine (entlast)) ; Reference line entity name (setq pt2 (getvar 'lastpoint)) ; pt2 of reference line (setq MySS (ssget "_f" (list pt1 pt2))) ; Selection set crossing reference line (fence). Add filters (setq acount 0) ; a counter (while (< acount (sslength MySS)) ; Loop through selection set (if (setq MyIntersect (LM:intersections (vlax-ename->vla-object MyLine)(vlax-ename->vla-object (ssname MySS acount)) acextendnone )) ; get the intersection points, reference line, selection set items (progn (foreach n MyIntersect (setq MyDistance (distance pt1 n)) ; get the distance SS item, start reference line (setq MyDistances (cons (cons MyDistance (list n)) MyDistances)) ;; add the intersection & point to a list ) ; end foreach ) ; end progn ) ; end if intersections (setq acount (+ acount 1)) ; increase counter ) ; end while ; end loop (command "erase" MyLine "") ; erase reference line (setq MyDistances (vl-sort MyDistances (function (lambda (pta ptb) (< (car pta)(car ptB) ))) )) ; sort by distance (setq acount 0) (while (< (+ acount 1) (length MyDistances)) (setq p1 (car (cdr (nth acount MyDistances)))) (setq p2 (car (cdr (nth (+ acount 1) MyDistances)))) (setq mid (mapcar '/ (mapcar '+ p1 p2) '(2 2 2))) ; ripped of MHUPP (setq p3 (mapcar '+ mid '(0.0 2.0 0.0))) ;adj 2.0 for offset. ; ripped of MUPP (command "_.DIMLINEAR" p1 p2 p3) ; Ripped of MHUPP (setq acount (+ acount 1)) ) ; end while (princ) ) Edit: Corrected for polylines crossing reference line more than once Edited 12 minutes ago by Steven P 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.