silverfish Posted June 14, 2009 Posted June 14, 2009 Firstly I would like to say hi to all here. My first post..... I work within the fire protection industry and do loads of 2d pipe layouts. I have created a dimension style without any lines and leaders to insert above the pipe. I have a suffix of the pipe diameter followed by an x.eg 32x then the dimension value...32x3000 What I need to do is subtract a value from the 3000 to represent the cut pipe length....32x2950 This subtracted value is to allow for deductions on screwed fittings. Is there a way to take the dimension value ie 3000mm and subtract a value of say 50mm off of it without doing an overide. Our drawings have hundreds of these cut lenghts and it would be too time consuming. I hope that my explanation is clear enough.....:wink: Thanks Bruce Quote
Lee Mac Posted June 14, 2009 Posted June 14, 2009 Something like this? (defun c:MacDim (/ ss num) (vl-load-com) (if (and (setq ss (ssget '((0 . "DIMENSION")))) (setq num (getreal "\nSpecify Alteration: "))) (mapcar (function (lambda (x) (vla-put-TextOverride x (rtos (+ (vla-get-Measurement x) num))))) (mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))))) (princ)) Quote
silverfish Posted June 14, 2009 Author Posted June 14, 2009 Hi Lee, Many thanks! Just tried it and it works except that once I select the dimension ie, 32x3000 and subtract 50 off of it I get 2950.000. I lose the prefix and formatting. Is there a way of setting up a dim style to deduct a certain value? Regards Bruce Quote
Lee Mac Posted June 14, 2009 Posted June 14, 2009 I'm not sure how to set up the dimension style so that it subtracts the value, but you could give this a try in any case: (defun c:MacDim (/ ss num) (vl-load-com) (if (and (setq ss (ssget '((0 . "DIMENSION")))) (setq num (getreal "\nSpecify Alteration: "))) (mapcar (function (lambda (x) (vla-put-TextOverride x (strcat (vla-get-TextPrefix x) (rtos (+ (vla-get-Measurement x) num) (vla-get-UnitsFormat x) (vla-get-PrimaryUnitsPrecision x)) (vla-get-TextSuffix x))))) (mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))))) (princ)) Quote
VVA Posted June 14, 2009 Posted June 14, 2009 I'm not sure how to set up the dimension style so that it subtracts the value As a variant it is possible to arrive thus: 1. To consider the size as the block (*D...). The block name is stored in dxf a code 2 2. To find in the table of blocks its description, and in it mtext and to take its value. (defun C:TEST ( / dim str) (and (setq dim (car (entsel "\nSelect dimention:"))) (= (cdr(assoc 0 (entget dim))) "DIMENSION") (setq str (dim-get-text-string dim)) ) (princ str) (princ) ) (defun dim-get-text-string ( dim / str) (setq str "") [color="Red"](vlax-for item (vla-item (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)) ) ;_ end of vla-get-Blocks (cdr (assoc 2 (entget dim))) ) ;_ end of vla-item (if (vlax-property-available-p item 'Textstring) (setq str (vla-get-textstring item))[/color] ) ) (mip_MTEXT_Unformat str) ) (defun mip_MTEXT_Unformat ( Mtext / text Str ) (setq Text "") (while (/= Mtext "") (cond ((wcmatch (strcase (setq Str (substr Mtext 1 2))) "\\[\\{}]") (setq Mtext (substr Mtext 3) Text (strcat Text Str))) ((wcmatch (substr Mtext 1 1) "[{}]")(setq Mtext (substr Mtext 2))) ((wcmatch (strcase (setq Str (substr Mtext 1 2))) "\\[LO`~]") (setq Mtext (substr Mtext 3))) ((wcmatch (strcase (substr Mtext 1 2)) "\\[ACFHQTW]") (setq Mtext (substr Mtext (+ 2 (vl-string-search ";" Mtext))))) ((wcmatch (strcase (substr mtext 1 4)) "\\PQ[CRJD],\\PXQ") ;;;Add by KPblC (setq mtext (substr mtext (+ 2 (vl-string-search ";" mtext)))) ) ((wcmatch (strcase (substr Mtext 1 2)) "\\P") (if (or (zerop (strlen Text)) (= " " (substr Text (strlen Text))) (= " " (substr Mtext 3 1))) (setq Mtext (substr Mtext 3)) (setq Mtext (substr Mtext 3) Text (strcat Text " ")))) ((wcmatch (strcase (substr Mtext 1 2)) "\\S") (setq Str (substr Mtext 3 (- (vl-string-search ";" Mtext) 2)) Text (strcat Text (vl-string-translate "#^\\" "/^\\" Str)) Mtext (substr Mtext (+ 4 (strlen Str))))) (t (setq Text (strcat Text (substr Mtext 1 1)) Mtext (substr Mtext 2))))) Text) Quote
Lee Mac Posted June 14, 2009 Posted June 14, 2009 Very nice VVA, but surely even with the Dimension Text String, you still have to do the Maths on it and that would mess with the formatting. Quote
silverfish Posted June 16, 2009 Author Posted June 16, 2009 Thanks for the input Guys! VVA = Loaded your lisp but got errors when trying to run it? Lee - Loaded your second version and works a treat. I have created different layers for the various diameters and now switch all other layers off and use your routine to multiple select all relevent dimensions that require the same deduction! Again, many thanks to you both silverfish Quote
Lee Mac Posted June 16, 2009 Posted June 16, 2009 Thanks for the input Guys!VVA = Loaded your lisp but got errors when trying to run it? Lee - Loaded your second version and works a treat. I have created different layers for the various diameters and now switch all other layers off and use your routine to multiple select all relevent dimensions that require the same deduction! Again, many thanks to you both silverfish Hey Bruce, Glad I could help out - I think VVA's LISP was more to provide me with help on a different way to extract the relevant information from the dimension, but I'm happy that my code met your requirements Lee Quote
VVA Posted June 16, 2009 Posted June 16, 2009 > Lee Mac I think VVA's LISP was more to provide me with help on a different way to extract the relevant information from the dimension Quote
silverfish Posted June 29, 2009 Author Posted June 29, 2009 Lee, I have been using your routine with great success...Thank you! I have another request! Is it possible to change the dimension colour once I have run the lisp file on it? I am getting a little confused as to which dimension I have worked on and which not! Thanks silverfish Quote
Lee Mac Posted June 29, 2009 Posted June 29, 2009 Not a problem (defun c:MacDim (/ ss num) (vl-load-com) (if (and (setq ss (ssget '((0 . "DIMENSION")))) (setq num (getreal "\nSpecify Alteration: "))) (mapcar (function (lambda (x) (vla-put-ExtensionLineColor x 1) ;; <<-- 1 = Red (vla-put-DimensionLineColor x 1) (vla-put-TextOverride x (strcat (vla-get-TextPrefix x) (rtos (+ (vla-get-Measurement x) num) (vla-get-UnitsFormat x) (vla-get-PrimaryUnitsPrecision x)) (vla-get-TextSuffix x))))) (mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))))) (princ)) Quote
silverfish Posted July 1, 2009 Author Posted July 1, 2009 Thanks Lee, What I'm looking for is to change the dim text colour not the extension lines as I have set the dim style up to turn off all extension lines, leaders and arrow heads so all you see is this "25x3000" which is what I want changed. Many Thank silverfish Quote
Lee Mac Posted July 1, 2009 Posted July 1, 2009 Thanks Lee,What I'm looking for is to change the dim text colour not the extension lines as I have set the dim style up to turn off all extension lines, leaders and arrow heads so all you see is this "25x3000" which is what I want changed. Many Thank silverfish Sorry, I wasn't exactly sure what you wanted. - Its not hard to change it, no worries Quote
Lee Mac Posted July 1, 2009 Posted July 1, 2009 Here ya go: (defun c:MacDim (/ ss num) (vl-load-com) (if (and (setq ss (ssget '((0 . "DIMENSION")))) (setq num (getreal "\nSpecify Alteration: "))) (mapcar (function (lambda (x) (vla-put-TextColor x 1) ; <<-- 1 = Red (vla-put-TextOverride x (strcat (vla-get-TextPrefix x) (rtos (+ (vla-get-Measurement x) num) (vla-get-UnitsFormat x) (vla-get-PrimaryUnitsPrecision x)) (vla-get-TextSuffix x))))) (mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))))) (princ)) Quote
silverfish Posted July 1, 2009 Author Posted July 1, 2009 Thanks again Lee, works perfectly! Perhaps you can answer this question I have. When doing the dimension is it possible to have the prefix above the line and the dimension value below the line. many thanks Quote
Lee Mac Posted July 1, 2009 Posted July 1, 2009 Use: "\X" like this: (defun c:MacDim (/ ss num) (vl-load-com) (if (and (setq ss (ssget '((0 . "DIMENSION")))) (setq num (getreal "\nSpecify Alteration: "))) (mapcar (function (lambda (x) (vla-put-TextColor x 1) ; <<-- 1 = Red (vla-put-TextOverride x (strcat (vla-get-TextPrefix x) "\\X" (rtos (+ (vla-get-Measurement x) num) (vla-get-UnitsFormat x) (vla-get-PrimaryUnitsPrecision x)) (vla-get-TextSuffix x))))) (mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))))) (princ)) Quote
silverfish Posted July 1, 2009 Author Posted July 1, 2009 You are truly a wizzard at this Lee! CHEERS Every time you help me on this I find I have another request......;-) Is it possible to move the prefix to a layer named "FPS SPRINKLER DIA" and the dimension value to a layer named "FPS SPRINKLER LIST" Many thanks Bruce Quote
Lee Mac Posted July 1, 2009 Posted July 1, 2009 You are truly a wizzard at this Lee! CHEERS Every time you help me on this I find I have another request......;-) Is it possible to move the prefix to a layer named "FPS SPRINKLER DIA" and the dimension value to a layer named "FPS SPRINKLER LIST" Many thanks Bruce The dimension is a single entity, and on its own layer, so without making the prefix and dimension strings out of separate entities, I don't think this is possible. Quote
Ryder Posted August 15, 2012 Posted August 15, 2012 Hi Guys I am too in the fire protection industry and have the same query as Bruce. I am well trained in Autocad but unfortunately my knowledge with regards to programming is very limited. Could you perhaps walk me through loading a LISP? Lee im on your website amd i am attempting to do it. Thanks In advance:D 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.