+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 12
  1. #1
    Forum Newbie
    Computer Details
    powpowmitch's Computer Details
    Operating System:
    W7
    Discipline
    See details...
    powpowmitch's Discipline Details
    Occupation
    Fire Protection
    Discipline
    See details below.
    Details
    Fire Protection / Sprinklers
    Using
    AutoCAD 2013
    Join Date
    Aug 2012
    Location
    New Zealand
    Posts
    6

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

    Registered forum members do not see this ad.

    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?
    Code:
    ;;;
    ;;;  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)
    )

  2. #2
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    15,743

    Default

    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.
    Lee Mac Programming

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

    Just another Swamper

  3. #3
    Forum Newbie
    Computer Details
    powpowmitch's Computer Details
    Operating System:
    W7
    Discipline
    See details...
    powpowmitch's Discipline Details
    Occupation
    Fire Protection
    Discipline
    See details below.
    Details
    Fire Protection / Sprinklers
    Using
    AutoCAD 2013
    Join Date
    Aug 2012
    Location
    New Zealand
    Posts
    6

    Default

    Lee Mac,

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

    codes to long to post. Igneus.lsp

  4. #4
    Forum Newbie
    Computer Details
    powpowmitch's Computer Details
    Operating System:
    W7
    Discipline
    See details...
    powpowmitch's Discipline Details
    Occupation
    Fire Protection
    Discipline
    See details below.
    Details
    Fire Protection / Sprinklers
    Using
    AutoCAD 2013
    Join Date
    Aug 2012
    Location
    New Zealand
    Posts
    6

    Default

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

  5. #5
    Senior Member nod684's Avatar
    Computer Details
    nod684's Computer Details
    Operating System:
    Windows 7 Home
    Discipline
    Architectural
    Using
    AutoCAD 2010
    Join Date
    Jul 2012
    Location
    Singapore
    Posts
    232

    Default

    try this one :

    Code:
     
    (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)
    )

    EDIT :

    oopss! sorry i misunderstood the post
    Last edited by nod684; 8th Aug 2012 at 10:56 am.
    "Memories fade but the scars still linger...."

  6. #6
    Forum Newbie
    Computer Details
    powpowmitch's Computer Details
    Operating System:
    W7
    Discipline
    See details...
    powpowmitch's Discipline Details
    Occupation
    Fire Protection
    Discipline
    See details below.
    Details
    Fire Protection / Sprinklers
    Using
    AutoCAD 2013
    Join Date
    Aug 2012
    Location
    New Zealand
    Posts
    6

    Default

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

  7. #7
    Forum Deity MSasu's Avatar
    Discipline
    Construction
    MSasu's Discipline Details
    Occupation
    engineer
    Discipline
    Construction
    Details
    AutoLISP programmer
    Using
    AutoCAD 2013
    Join Date
    Mar 2009
    Location
    Brasov, Romania
    Posts
    3,007

    Default

    Something like this?
    Code:
    (defun RoundToNearestFive( theNumber / theDifference )
     (setq theDifference (rem theNumber 5.0))
     
     (if (< theDifference 2.5)
      (setq theNumber (- theNumber theDifference))
      (setq theNumber (+ theNumber (- 5 theDifference)))
     )
     
     theNumber
    )
    Regards,
    Mircea

    AutoCAD's happy user equation: FILEDIA + PICKADD² + PICKFIRST = 3

  8. #8
    Forum Newbie
    Computer Details
    powpowmitch's Computer Details
    Operating System:
    W7
    Discipline
    See details...
    powpowmitch's Discipline Details
    Occupation
    Fire Protection
    Discipline
    See details below.
    Details
    Fire Protection / Sprinklers
    Using
    AutoCAD 2013
    Join Date
    Aug 2012
    Location
    New Zealand
    Posts
    6

    Default

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

  9. #9
    Super Member irneb's Avatar
    Computer Details
    irneb's Computer Details
    Operating System:
    Win7 Pro 64bit
    Computer:
    Antec One Hundred
    Motherboard:
    ASUS P8P67-Pro P67
    CPU:
    Intel i7 2600 @ 3.4GHz
    RAM:
    16GB-1600MHz
    Graphics:
    GeForce GT 430 (1GB)
    Primary Storage:
    Seagate1TB SATA2 - 7200rpm
    Monitor:
    Samsung 2333TN 23" 1920 x 1080 Full HD LCD Monitor2GW
    Discipline
    Architectural
    irneb's Discipline Details
    Occupation
    Architectural Technician and Programmer
    Discipline
    Architectural
    Using
    AutoCAD 2013
    Join Date
    Sep 2010
    Location
    Jo'burg SA
    Posts
    1,635

    Default

    On line 651 in the LSP file you need to change this:
    Code:
    (setq pLength (distance pStart pEnd))
    To look like this
    Code:
    (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").
    Knowledge is proportional to experience, but wisdom is inversely proportional to ego!
    My little bit of "wisdom": Hind-sight is useless, unless used to improve the next forethought!

  10. #10
    Forum Newbie
    Computer Details
    powpowmitch's Computer Details
    Operating System:
    W7
    Discipline
    See details...
    powpowmitch's Discipline Details
    Occupation
    Fire Protection
    Discipline
    See details below.
    Details
    Fire Protection / Sprinklers
    Using
    AutoCAD 2013
    Join Date
    Aug 2012
    Location
    New Zealand
    Posts
    6

    Default

    Registered forum members do not see this ad.

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

    I use this to Dim Fire sprinkler drawings

Similar Threads

  1. I need lisp for calculating length of all line and area of slected atem.
    By afrazawan in forum AutoLISP, Visual LISP & DCL
    Replies: 2
    Last Post: 20th Nov 2011, 01:36 pm
  2. Replies: 2
    Last Post: 11th Oct 2011, 12:41 pm
  3. Lisp to create an offset construction line with indefinite length.
    By stevsmith in forum AutoLISP, Visual LISP & DCL
    Replies: 5
    Last Post: 6th Jul 2011, 05:19 pm
  4. Tough Questions - Line Length Lisp
    By johnshar123xx in forum AutoLISP, Visual LISP & DCL
    Replies: 2
    Last Post: 30th Nov 2009, 11:43 pm
  5. Need a code lisp sum the length of line, pline, arc..
    By Nad SK in forum AutoLISP, Visual LISP & DCL
    Replies: 2
    Last Post: 4th Dec 2008, 08:53 am

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts