CAP Posted January 28 Posted January 28 Afternoon All, I'm looking for a lisp that would adapt an existing dimension and change this to show the original output + a further output that gave the original number divided by a given length of 3000. So, if we have a dimension of 1500 we have an output of "1500mm - 1 No 3000mm length", dimension of 6450 an output of "6450 - 3 No 3000mm length" etc. The existing dimensions could be selected individually or a crossing selection. Alternatively, rather than selecting dimensions, would it be possible to simply select a bunch of lines and automatically produce the same output dimensions I did find a lisp posted by @irneb from back in 2011, but, it doesn't quite work for me. For instance when the selected dimension is broken up into multiples of 3000 leaving a remaining section that is less than half the 3000mm then it doesn't count the part left over. i.e 2800 gives 1 @ 3000, 3000 gives 1 @ 3000, 4450 gives 1 @ 3000 but 4600 gives 2 @ 3000 (See attached). The original lisp was (thanks @irneb) : On 9/27/2011 at 3:46 PM, irneb said: Anyhow, if you want it as a lisp: (defun c:@Dims (/ dist ss n eo) (if (and (setq dist (getdist "\nSpecify increment distance: ")) (setq ss (ssget '((0 . "DIMENSION")))) ) (progn (setq n (sslength ss)) (while (> (setq n (1- n)) -1) (setq eo (vlax-ename->vla-object (ssname ss n))) (vla-put-AltUnitsScale eo dist) (vla-put-LinearScaleFactor eo (/ 1.0 dist)) (vla-put-TextOverride eo (strcat "[%<\\AcExpr (1+%<\\AcObjProp Object(%<\\_ObjId " (itoa (vla-get-ObjectID eo)) ">%).Measurement \\f \"%lu2%pr0\">%) \\f \"%lu2%pr0\">%]\\X@ %<\\AcObjProp Object(%<\\_ObjId " (itoa (vla-get-ObjectID eo)) ">%).AltUnitsScale \\f \"%lu2%pr0\">% C/C" ) ) (vla-Update eo) ) ) ) (command "._UpdateField" ss "") (princ) ) Expand Quote
CAP Posted Wednesday at 09:03 AM Author Posted Wednesday at 09:03 AM Hi @hosneyalaa, thanks for the reply. Its basically as per the screenshot above, however, please see attached .dwg. When recreating the example this morning, the results appear different from those produced previously - now I'm confused even more example.dwgFetching info... Quote
BIGAL Posted Friday at 04:06 AM Posted Friday at 04:06 AM (edited) The 4600 is wrong should be 2 not 3 is it not a length / 3000 then take the fix so / 4450 3000 = 1.483 so you have a fraction greater than 0.0 and the number is just add 1 to the fix of the length. This would be using a simple lisp adding field formulas may be difficult. I would also do a check equal with a factor of like 1e-8 as sometimes a 3000 can be 3000.00000001. May have time later, really no need for a dim just pick line. Edited Friday at 04:08 AM by BIGAL Quote
BIGAL Posted Sunday at 04:43 AM Posted Sunday at 04:43 AM (edited) Ok got the math working, do you just need them labelled say Text or need a dim with 2x@3000 and so on. (defun c:wow ( / end ent frac howmany len mp obj start) (while (setq ent (entsel "\nPick a line Enter to exit ")) (setq obj (vlax-ename->vla-object (car ent))) (setq len (vlax-get obj 'length)) (setq start (vlax-curve-getstartPoint obj)) (setq end (vlax-curve-getEndPoint obj)) (setq howmany (/ len 3000.)) (setq frac (- howmany (fix howmany))) (if (< howmany 1.0) (setq howmany 1.0) (if (> frac 0.0) (setq howmany (+ (fix howmany) 1)) ) ) (setq mp (mapcar '* (mapcar '+ start end) '(0.5 0.5))) (setq ang (angle start end)) (setq mp (polar mp (+ ang (/ pi 2))250)) (command "text" "s" "Standard" mp 250 0.0 (strcat (rtos howmany 2 0) " X @3000")) ) (princ) ) Edited yesterday at 12:40 AM by BIGAL Quote
CAP Posted Sunday at 12:35 PM Author Posted Sunday at 12:35 PM Hi @BIGAL, thats certainly a massive step in the right direction. If you can get a label stating "x No @ 3000mm" that would be perfect. Thanks for your effort. Quote
BIGAL Posted yesterday at 12:38 AM Posted yesterday at 12:38 AM (edited) Code updated above. Could be a dim if you want, I will let you do that. Edited yesterday at 12:41 AM by BIGAL Quote
CAP Posted 15 hours ago Author Posted 15 hours ago Thats great @BIGAL, exactly what i was after, thanks for your help on that Quote
BIGAL Posted 8 hours ago Posted 8 hours ago Just be aware that I did not check direction of line so if drawn right to left the label will go under rather than on top. Could check for that though. Happy to help. 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.