Easy ?

Discussion in 'AutoCAD' started by thenrich, Oct 25, 2004.

  1. thenrich

    thenrich Guest

    How would I set a default for the 'Scale factor:' to = my USERR4 variable?

    (setq ds (/ (GETREAL "Scale factor: ") 2)
    plw (* 0.000 ds) ;plw sets the pline width
    oer *error*
    bm (getvar "blipmode")
    )
     
    thenrich, Oct 25, 2004
    #1
  2. thenrich

    T.Willey Guest

    (getvar "userr4")

    Tim
     
    T.Willey, Oct 25, 2004
    #2
  3. thenrich

    thenrich Guest

    That much I knew but I still wanna ask the user to enter in a val if they need to else just enter and accept the default value.

    My Bad - I prolly worded the question wrong.
     
    thenrich, Oct 25, 2004
    #3
  4. thenrich

    thenrich Guest

    I want something like this:
    Scale factor <8>:

    and for it to work.....
     
    thenrich, Oct 25, 2004
    #4
  5. thenrich

    T.Willey Guest

    (setq ds (getreal (strcat "\n Enter scale factor <" (rtos (getvar "userr4") 2 0) ">: ")))
    (if (not ds)
    (setq ds (getvar "userr4"))
    )

    I think this is what you want. Sorry about the mix up.
    Tim
     
    T.Willey, Oct 25, 2004
    #5
  6. thenrich

    thenrich Guest

    How can I adjust this so if I'm in modelspace use userr4 and in paperspace use 1?
     
    thenrich, Oct 26, 2004
    #6
  7. thenrich

    T.Willey Guest

    Check the "cvport" system var. If it's 1 then you're in paper space, any other number you're in some form of model space.

    Hope that helps.
    Tim
     
    T.Willey, Oct 26, 2004
    #7
  8. thenrich

    thenrich Guest

    How would I ask that using an 'If' statement and set a variable with either the userr4 or 1 value. Also can I get the same thing by asking TILEMODE?
     
    thenrich, Oct 26, 2004
    #8
  9. thenrich

    thenrich Guest

    here is the code now and it keeps failing:

    (defun C:CL1 (/ bm bulge_fctr ds OCL oer OS_MODE p1 plw PT1 pt2 spcsx spcsy xdist ydist)
    (setvar "cmdecho" 0)

    (setq OCL (getvar "clayer"))
    (setvar "clayer" "text")
    (setq OS_MODE (getvar "osmode"))
    (setvar "osmode" 0)


    (setq tMode (getvar "TILEMODE"))
    (setq Val (if (= tMode 1)
    (getvar "userr4")
    1.0
    )
    )

    (setq TMP (getreal
    (strcat "Scale factor <" (rtos (Val)) ">: ")
    )
    )
    (if (not TMP)
    (setq TMP (Val))
    )

    (setq DS (/ TMP 2)
    PLW (* 0.000 DS) ;plw sets the pline width
    OER *ERROR*
    BM (getvar "blipmode")
    )

    (defun *error* (s) ;start error routine
    (setvar "blipmode" bm) ;reset blipmode
    (princ (strcat "\Exit..." s)) ;type error message
    (if oer (setq *error* oer))
    (princ))

    (SETQ PT1 (GETPOINT "Pick lower left corner of window: ")) (terpri)
    (setq pt2 (getcorner pt1 "Pick upper right corner of window: "))
    (setvar "blipmode" 0)
    (setq p1 (car pt1) p2 (car pt2) ;find x distances
    xdist (- p2 p1))
    (setq p1 (cadr pt1) p2 (cadr pt2) ;find y distances
    ydist (- p2 p1))

    ;******TO ADJUST SPACING OF ARCS CHANGE THE NUMBER 2 IN THE NEXT TWO LINES*****
    (setq spcsx (/ (abs xdist) (/ ds 2)) ;X spacing
    spcsy (/ (abs ydist) (/ ds 2))) ;Y spacing

    (if (= spcsx (fix spcsx)) (setq spcsx (fix spcsx)) (setq spcsx (+ 1 (fix
    spcsx))))
    (if (= spcsx 1) (setq spcsx 2)) ;min of 2 spaces
    (if (= spcsy (fix spcsy)) (setq spcsy (fix spcsy)) (setq spcsy (+ 1 (fix
    spcsy))))
    (if (= spcsy 1) (setq spcsy 2)) ;min of 2 spaces

    (setq xdist (/ xdist spcsx) ydist (/ ydist spcsy)) ;set distances

    (setq p1 pt1) ;set polyline start
    point

    ;;;;add arcs to pline WJC
    ;;;(setq bulge_fctr (* xdist 1.2))

    (command "PLINE" p1 "W" plw "" "a") ;start polyline
    command
    (setq bulge_fctr (* xdist 0.65))
    (repeat spcsx ;draw bottom line
    segments
    (setq p1 (polar p1 0.0 (abs xdist)))
    (command "r" bulge_fctr p1))
    (setq bulge_fctr (* ydist 0.65))
    (repeat spcsy ;draw right line
    segments
    (setq p1 (polar p1 (/ pi 2) (abs ydist)))
    (command "r" bulge_fctr p1))
    (setq bulge_fctr (* xdist 0.65))
    (repeat spcsx ;draw top line segments
    (setq p1 (polar p1 pi (abs xdist)))
    (command "r" bulge_fctr p1))
    (setq bulge_fctr (* ydist 0.65))
    (repeat (- spcsy 1) ;draw left line
    segments
    (setq p1 (polar p1 (* pi 1.5) (abs ydist)))
    (command "r" bulge_fctr p1))
    (command "r" bulge_fctr pt1 "")
    ;Close polyline

    (setvar "blipmode" bm) ;reset blipmode
    (setvar "cmdecho" 1) ;turn command echo on
    (setvar "clayer" OCL)
    (setvar "osmode" OS_MODE)
    (princ) ;print blank line
    )
     
    thenrich, Oct 26, 2004
    #9
  10. thenrich

    T.Willey Guest

    (setq tMode (getvar "CVPORT")); changed this line
    (setq Val (if (= tMode 1)
    1.0 ; reordered your if statement
    (getvar "userr4") ; switch the two lines
    )
    )

    Tim
     
    T.Willey, Oct 26, 2004
    #10
  11. thenrich

    thenrich Guest

    It's just not my day -

    error: An error has occurred inside the *error* functionAutoCAD variable
    setting rejected: "blipmode" nil
     
    thenrich, Oct 26, 2004
    #11
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.