See the top rated post in this thread. Click here

Results 1 to 9 of 9

Thread: Simple routine to set user variables.

  1. #1
    Active Member keelay711's Avatar
    Join Date
    2004-11
    Location
    San Diego, CA
    Posts
    84
    Login to Give a bone
    1

    Default Simple routine to set user variables.

    This is one I cooked up the first day I learned about the basics of AutoLISP. Perhaps a newer CAD user will benefit from this one. Just add or replace variables that are important to you.

    There is one error in the code, though I can't figure it out for the life of me. The following line works like a charm if point (0,0,0) is not visible on screen when the code runs. But it IS visible on screen, the code balks at the last input. It requires you to enter the "0,0,1" manually, and then finishes fine.

    The dview command works perfectly well when invoked on the command line, and this line of code copies the input verbatim. So why the hangup?

    Code:
    ; sets camera to default position, which is required to print to limits correctly
    
    (command "dview" "all" "" "PO" "0,0,0" "0,0,1" "")
    Attached Files Attached Files

  2. #2
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    9,106
    Login to Give a bone
    0

    Default Re: Simple routine to set user variables.

    Most, if not all, of those are system variables. Why do you want to echo those variables to the text screen? You could set them with the setvar AutoLISP function.
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  3. #3
    AUGI Addict madcadder's Avatar
    Join Date
    2000-11
    Location
    Too far from the beach
    Posts
    1,054
    Login to Give a bone
    1

    Default Re: Simple routine to set user variables.

    From the two posts that I've read... They both contain something along the lines of "proper visual verification to the user".

    Who is this user that doesn't have faith in what their sup/mgr is doing and feels they must recheck this every time a drawing is opened or this routine is run?

    Attached is my "strange too" method of an acaddoc.lsp. You will note there is a message at the beginning of each section and one at the end. If both messages are not displayed then the code bombed in the middle and I didn't muddle up the screen.
    Attached Files Attached Files

  4. #4
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    9,106
    Login to Give a bone
    0

    Default Re: Simple routine to set user variables.

    Quote Originally Posted by madcadder
    From the two posts that I've read... They both contain something along the lines of "proper visual verification to the user".

    Who is this user that doesn't have faith in what their sup/mgr is doing and feels they must recheck this every time a drawing is opened or this routine is run?

    Attached is my "strange too" method of an acaddoc.lsp. You will note there is a message at the beginning of each section and one at the end. If both messages are not displayed then the code bombed in the middle and I didn't muddle up the screen.
    Tod, very informative on those comments.
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  5. #5
    Active Member keelay711's Avatar
    Join Date
    2004-11
    Location
    San Diego, CA
    Posts
    84
    Login to Give a bone
    0

    Default Re: Simple routine to set user variables.

    Quote Originally Posted by Opie
    Most, if not all, of those are system variables. Why do you want to echo those variables to the text screen? You could set them with the setvar AutoLISP function.
    There are a couple individuals here in the Cad Cave who are picky about knowing what their computer is doing. When the Clean.lsp routine is run, they wanted to see exactly what it did. Hey, it makes them more comfortable users and it doesn't hurt anything to write the lisp in that fashion, so why not?

    In addition, since this was a very early routine for me, I wanted the visual queue of what went right and what went wrong. Seeing on my F2 screen that the variables updated correctly up until [ex] "fieldeval" told me exactly where in my code I screwed up. I saw no need to rewrite it to use setvar after I knew what I was doing.

    Referencing the question I add about the dview command, should I create a new post specifically for that?

  6. #6
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL USA
    Posts
    3,667
    Login to Give a bone
    0

    Default Re: Simple routine to set user variables.

    Quote Originally Posted by keelay711
    There are a couple individuals here in the Cad Cave who are picky about knowing what their computer is doing. When the Clean.lsp routine is run, they wanted to see exactly what it did. Hey, it makes them more comfortable users and it doesn't hurt anything to write the lisp in that fashion, so why not?
    Most users don't like having their Autocad vars messed with. Test the Autocad vars and only modify them if nessisary. Then notify the user of the changes that needed to be made. If standards are being used no changes may be needed.
    Code:
     (if (/= (getvar "angbase") 0)(progn(setvar "angbase" 0)(princ "\nSet base angle to 0 (East).")))
    (if (/= (getvar "angdir") 0)(progn(setvar "angdir" 0)(princ "\nSet angle direction to counterclockwise.")))
    (if (/= (getvar "aunits") 4)(progn(setvar "aunits" 4)(princ "\nSurvey units.")))
    (if (/= (getvar "auprec") 3)(progn(setvar "auprec" 3)(princ "\nSet angle precision to ddd°-mm'-ss\".")))
    (if (= (getvar "autosave") 0)(progn(setvar "autosave" 15)(princ "\nAutosave every 15 minutes.")))
    Quote Originally Posted by keelay711
    Referencing the question I add about the dview command, should I create a new post specifically for that?
    I tested it and it worked ok on my machine in 2007. When 0,0 wasn't visable it put me there though. Took a couple of zooms to get back. Were you getting some kind of error message?

  7. #7
    AUGI Addict kennet.sjoberg's Avatar
    Join Date
    2002-05
    Posts
    1,707
    Login to Give a bone
    0

    Default Re: Simple routine to set user variables.

    Quote Originally Posted by keelay711
    There are a couple individuals here in the Cad Cave who are picky about knowing what their computer is doing. . .
    . . . and about the registry writing, AutoCAD change your registry keys at least 50 times per seconds. . .
    textscreen all over the individuals face or ?

    : ) Happy Computing !

    kennet

  8. #8
    Active Member keelay711's Avatar
    Join Date
    2004-11
    Location
    San Diego, CA
    Posts
    84
    Login to Give a bone
    0

    Default Re: Simple routine to set user variables.

    Quote Originally Posted by Tom Beauford
    I tested it and it worked ok on my machine in 2007. When 0,0 wasn't visable it put me there though. Took a couple of zooms to get back. Were you getting some kind of error message?
    Code:
    Command: dview
    Select objects or <use DVIEWBLOCK>: all 581 found
    
    Select objects or <use DVIEWBLOCK>:
    Enter option
    [CAmera/TArget/Distance/POints/PAn/Zoom/TWist/CLip/Hide/Off/Undo]: PO
    Specify target point <28'-0.1840", 8'-11.0408", 0'-0.0000">: 0,0,0
    Specify camera point <28'-0.1840", 8'-11.0408", 0'-1.0000">: 0,0,1
    Camera and Target may not be coincident
    ; error: Function cancelled
    
    Specify camera point <28'-0.1840", 8'-11.0408", 0'-1.0000">:
    This was clipped straight from the drawing. The "clean" routine was run with the 0,0 point visible on screen. Had I run it with the 0,0 offscreen, it would have accepted the camera point input with no problems. Entering the 0,0,1 manually after the code fails completes the command without a problem.

  9. #9
    Member
    Join Date
    2006-10
    Location
    Sydney
    Posts
    20
    Login to Give a bone
    0

    Smile Re: Simple routine to set user variables.

    Quote Originally Posted by keelay711 View Post
    The "clean" routine was run with the 0,0 point visible on screen. Had I run it with the 0,0 offscreen, it would have accepted the camera point input with no problems. Entering the 0,0,1 manually after the code fails completes the command without a problem.
    Old thread, I know but it is still broken in AutoCAD 2010. as a workaround I zoomed the drawing to 10,10 - 20,20, executed the command and then zoomed previous - *Twice*. Yeah, twice. I dunno - I don't ask anymore.

    Code:
    DEFUN C:FIXTXT () ;Shortcut fix text rendering problems . 1st ditch the AEC render DLLs
    (COMMAND "zoom" "window" "10,10" "20,20" "-purge" "R" "*" "n" "dview" "ALL" "" "points" "0.00,0.00,0.00" "0.00,0.00,1.00" "" "zoom" "previous" "zoom" "previous") 	; then move the camera in 3D space to a 2D-friendly point
    )

Similar Threads

  1. user variables in Revit API
    By Ning Zhou in forum Revit - API
    Replies: 6
    Last Post: 2009-07-31, 07:07 PM
  2. A simple routine
    By mert523 in forum AutoLISP
    Replies: 14
    Last Post: 2008-12-08, 05:32 PM
  3. Replies: 2
    Last Post: 2007-04-20, 09:51 AM
  4. Variables & User Forms
    By lillian.twining in forum VBA/COM Interop
    Replies: 9
    Last Post: 2006-01-09, 06:03 PM

Posting Permissions

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