Jump to content

LISP dim line length but want to rund up to nearest 5


Recommended Posts

Posted

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)
)

Posted

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.

Posted

Lee Mac,

 

I want the length that displays under the line to round to the nearest 5mm.

 

codes to long to post. Igneus.lsp

Posted

Can anyone else help on this? I have attached the entire lsp above... look forward to some help.

Posted (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 by nod684
Posted

Lee Mac - Really keen to see if you can solve this for me please mate? ^^

Posted

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
)

Posted
Igneus.lspMSasu Where do I fit that into the attached code? maybe you could amend for me and reupload?? Please :)
Posted

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").

Posted

MitchPDIM.lsp Thakyou so Much its working.... :) I have attached for anyone interested.

 

I use this to Dim Fire sprinkler drawings

  • 7 months later...
Posted

Open the file with Notepad and right in its header you will find the description of the commands.

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...