vernonlee Posted October 7, 2014 Author Posted October 7, 2014 CENT does not work on right side drawing.dwg I have attached the drawing for any advise. The LSP programme canwork on the drawing on the left. center lines can be highlighted with dimension. But the right side drawing is not able to. Please advise. Thanks Quote
7o7 Posted October 7, 2014 Posted October 7, 2014 You right side drawing is bigger in width than the left, so the routine doesn't work, because I only think that maximun width is about 500. Could you tell the biggest wall you have? Quote
vernonlee Posted October 7, 2014 Author Posted October 7, 2014 (edited) You right side drawing is bigger in width than the left, so the routine doesn't work, because I only think that maximun width is about 500.Could you tell the biggest wall you have? oh. As far as i can remember the biggest wall is 1m. But best to take 2m for allowance if possible. Else 1.5m? Thanks bro. edit By the way, my drawings also have curve polylines as well. Edited October 7, 2014 by vernonlee Quote
7o7 Posted October 8, 2014 Posted October 8, 2014 Try this and let me know if there is error. This routine is not dependant to wall width but after choosing a pline to get layer you have to select all surrounding object to measure the distances. (defun c:cent(/ a ss ss0 ss1 ss2 prec1 os) (vl-load-com) (defun midp(d1 d2) (polar d1 (angle d1 d2) (* 0.5 (distance d1 d2)))) (defun getp(v / l1) (setq l1 (mapcar 'cdr (vl-remove-if-not '(lambda(x) (= (car x) 10)) (entget v))) l1 (if (or (= 1 (cdr (assoc 70 (entget v)))) (equal (car l1) (last l1) 0.001)) (mapcar 'list l1 (append (cdr l1) (list (car l1)))) (mapcar 'list l1 (cdr l1) ))) l1 ) (defun getnear (pt1 pt2 / ss3 tm tm1 pt) (setq pt (midp pt1 pt2) ss3 (vl-remove-if-not '(lambda(x) (equal (abs (cos (+ (* 0.5 pi) (angle pt1 pt2)))) (abs (cos (angle pt (vlax-curve-getClosestPointTo x pt)))) 0.001)) ss2) tm (vl-sort ss3 '(lambda(x y) (< (distance pt (vlax-curve-getClosestPointTo x pt)) (distance pt (vlax-curve-getClosestPointTo y pt)))))) (list (list pt (setq tm1 (vlax-curve-getClosestPointTo (car tm) pt)) (distance pt tm1)) (list pt (setq tm1 (vlax-curve-getClosestPointTo (cadr tm) pt)) (distance pt tm1))) ) (defun getdis(pt1 pt2 v / tm tm1 tm2) (if (and (setq tm (getnear pt1 pt2) tm1 (car tm) tm2 (last tm)) (not (equal (rtos (last tm1) 2 prec) (rtos (last tm2) 2 prec))) (equal (last tm1) (last tm2) 10) ) (progn (ssadd v ss0) (command "dimaligned" (car tm1) (cadr tm1) (car tm1)) (command "dimaligned" (car tm2) (cadr tm2) (car tm2)) ) ) ) (command "undo" "be") (setvar 'cmdecho 0) (setq prec1 (getint (strcat "\nPrecision <" (itoa (if (not prec) (setq prec 0) prec)) ">:")) os (getvar 'osmode)) (if prec1 (setq prec prec1)) (setvar 'dimdec prec) (setq a (car (entsel "\nChoose a polyline of center wall:")) ss0 (ssadd) ss (vl-remove-if 'listp (mapcar 'cadr (ssnamex (ssget '((0 . "*LINE")))))) ss1 (vl-remove-if-not '(lambda(x) (= (cdr (assoc 8 (entget a))) (cdr (assoc 8 (entget x))))) ss) ss2 (vl-remove-if '(lambda(x) (member x ss1)) ss) ) (setvar 'osmode 0) (foreach v ss1 (mapcar '(lambda(x) (getdis (car x) (last x) v)) (getp v)) ) (command "undo" "e") (setvar 'cmdecho 1) (setvar 'osmode os) (if (> (sslength ss0) 0) (sssetfirst nil ss0)) (princ) ) Quote
vernonlee Posted October 9, 2014 Author Posted October 9, 2014 (edited) Try this and let me know if there is error. This routine is not dependant to wall width but after choosing a pline to get layer you have to select all surrounding object to measure the distances. Hi bro, i have tested it. Tested the right side of the dwg - Dimension appeared - But "not centered" lines not highlighted like previous lisp - not sure why got a error at the last line (is this important?) Command: (LOAD "D:/Office/AutoCAD/lsp/Test/test center line.LSP") C:CENT Command: CENT undo Current settings: Auto = On, Control = All, Combine = Yes, Layer = Yes Enter the number of operations to undo or [Auto/Control/BEgin/End/Mark/Back] : be Command: Precision : Choose a polyline of center wall: Select objects: Specify opposite corner: 1225 found Select objects: ; error: unable to get ObjectID: nil Tested on my actual dwg -no dimension appeared (i made sure there are no block in my drawings) - Would the size of the drawing be the cause of this? 74808 as compared to the test dwg which is only 1225 - I also tried to select a smaller portion of the drawing instead of the whole drawing, it also would not work Command: CENTPrecision : Choose a polyline of center wall: Select objects: Specify opposite corner: 74808 found Select objects: ; error: unable to get ObjectID: nil 7o7, would it help if i email to you my actual drawings for a better picture? Could ypu PM me your email? Thanks Edited October 9, 2014 by vernonlee Quote
7o7 Posted October 9, 2014 Posted October 9, 2014 I have sent you a message to your Notifications. Quote
RobDraw Posted October 9, 2014 Posted October 9, 2014 A couple of comments: Get the drawings done right in the first place. Just tell them that the files are not usable because of this issue. Exploding blocks is only going to make the checking process slower. If you find a block that is not correct, edit it and all the others will be corrected. No need to check it again. This kind of checking should not be necessary. Sometimes it's easier to just do it right in the first place. 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.