powpowmitch Posted August 3, 2012 Posted August 3, 2012 Hi, I am dimming lines for fire protection in 2D. essentially these lines are pipes. I have found a good lisp routine that puts the pipes size and length on the drawing. its perfect. But I want the dims to round up to 5 ie. 3253 would go to 3255mm I have posted my code below, can someone help? ;;; ;;; PipeDim ;;; ;;; Description ;;; ----------- ;;; PIPEDIM creates length and size dimension text for each pipe selected. ;;; (defun c:pipedim( / pipedim_ss j) ; Call initialization function (igneus_init) ; get pipe size to use (if (null igneus_curPipeSize) (setq igneus_curPipeSize 1.0)) (setq j igneus_curPipeSize) (if (null (setq igneus_curPipeSize (getReal (strcat '"Enter pipe size <" (rtos igneus_curPipeSize 2 2) '">:")))) (setq igneus_curPipeSize j)) ; Let the use select the pipe to dimension (princ "\nSelect pipe to dimension") (setq pipedim_ss (ssget)) ;;; Dimension each line in the selection set (setq j 0) (while (< j (ssLength pipedim_ss)) (if (= '"LINE" (cdr (assoc 0 (entget (ssname pipedim_ss j))))) (pipedim_entity (ssname pipedim_ss j) igneus_curPipeSize igneus_footchar)) (setq j (+ j 1)) ) (igneus_end) ) Quote
Lee Mac Posted August 3, 2012 Posted August 3, 2012 Are you looking to round the value of the 'igneus_curPipeSize' variable? Without seeing the whole program it is difficult to assist you, as you are missing the definitions for the igneus_init & igneus_end functions but more importantly, the pipedim_entity function. Quote
powpowmitch Posted August 3, 2012 Author Posted August 3, 2012 Lee Mac, I want the length that displays under the line to round to the nearest 5mm. codes to long to post. Igneus.lsp Quote
powpowmitch Posted August 7, 2012 Author Posted August 7, 2012 Can anyone else help on this? I have attached the entire lsp above... look forward to some help. Quote
nod684 Posted August 8, 2012 Posted August 8, 2012 (edited) try this one : (defun c:Test (/ )(setq CmdOld (getvar "cmdecho")) (setvar "cmdecho" 0) (setq DIMNEW (entsel "\n Select Dimension to Round Off:"))(command "dimoverride" "dimrnd" "5" "" DIMNEW) (setvar "cmdecho" CmdOld) (princ)) [/Code] EDIT : oopss! sorry i misunderstood the post Edited August 8, 2012 by nod684 Quote
powpowmitch Posted August 16, 2012 Author Posted August 16, 2012 Lee Mac - Really keen to see if you can solve this for me please mate? ^^ Quote
MSasu Posted August 16, 2012 Posted August 16, 2012 Something like this? (defun RoundToNearestFive( theNumber / theDifference ) (setq theDifference (rem theNumber 5.0)) (if (< theDifference 2.5) (setq theNumber (- theNumber theDifference)) (setq theNumber (+ theNumber (- 5 theDifference))) ) theNumber ) Quote
powpowmitch Posted August 16, 2012 Author Posted August 16, 2012 Igneus.lspMSasu Where do I fit that into the attached code? maybe you could amend for me and reupload?? Please Quote
irneb Posted August 16, 2012 Posted August 16, 2012 On line 651 in the LSP file you need to change this: (setq pLength (distance pStart pEnd)) To look like this (setq pLength (RoundToNearestFive (distance pStart pEnd))) Then you need to have MSasu's code loaded into the drawing as well so that the RoundToNearestFive function is available. Easiest way would be to simply copy it into the igneus.lsp file (say just before line 919 "; default settings"). Quote
powpowmitch Posted August 16, 2012 Author Posted August 16, 2012 MitchPDIM.lsp Thakyou so Much its working.... I have attached for anyone interested. I use this to Dim Fire sprinkler drawings Quote
MSasu Posted March 18, 2013 Posted March 18, 2013 Open the file with Notepad and right in its header you will find the description of the commands. 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.