AutoCAD Macros

Discussion in 'AutoCAD' started by Mark Gonzales, Feb 17, 2004.

  1. Hello. I'm trying to get some macros I've written for LT to work in regular
    AutoCAD using a similar syntax. Here are some short examples...

    ========
    I'm trying to save the last point picked as a registry setting using:

    [&Pick Point]^C^C_id \(setenv "ActivePt" (getvar "lastpoint"))

    I get the following error:

    Command: (setenv "ActivePt" (getvar "lastpoint")) ; error: bad argument
    type:
    stringp (1.62005 41.933 0.0)

    Can anyone help?

    ========
    Also, can anyone tell me why this works?

    [Save]^C^C(setenv "Temp1" (getvar "clayer"))

    But this doesn't?

    [Save]^C^C(setenv "Temp1" (getvar "clayer"))_line
    ========


    Thanks,
    Mark
     
    Mark Gonzales, Feb 17, 2004
    #1
  2. Ok, for whatever reason, this now works in regular AutoCAD:

    [Example]^C^C(setenv "Temp1" (getvar "clayer")) _line

    WooHOO!


    And this works:

    [Example]^C^C(setenv "Temp1" (getstring "Temp1 Value: "))


    But this still doesn't work:

    [Example]^C^C(setenv "Temp1" (getstring "Temp1 Value: ")) _line

    It seems that I can't prompt the user for a Setenv value and then continue
    with the macro. :-( Any suggestions?

    Also, the Setenv command in LT gives the current value as the default. For
    example:

    ==============
    Command: setenv
    Enter variable name: Temp1
    Value: Mark

    Command:
    Command:
    SETENV Enter variable name: Temp1
    Value <Mark>:

    Command:
    ==============

    Is it possible for regular AutoCAD to do this as well?
     
    Mark Gonzales, Feb 18, 2004
    #2
  3. Mark Gonzales

    Paul Turvill Guest

    How about:

    [Example]^C^C(setenv "Temp1" (getstring "Temp1 Value: "))(command "_.line")
    ___
     
    Paul Turvill, Feb 18, 2004
    #3
  4. "_.line")

    Thanks for the response Paul, but it's still a NoGo for me, even after
    removing the "." before "line". :-(

    I'm ready to give up trying to use regular AutoCAD's Setenv LISP function.
    Even if I did get it to work, it still won't be as robust as LT's SETENV
    command which gives the current value as the default prompt.

    Please consider my situation below and advise me on my best course of
    action.

    I have written literally hundreds if not over a thousand AutoCAD LT macros
    and to my surprise, more than 90% of them work in regular AutoCAD so far
    with only minimum tweaking. I don't know LISP nor how to program in regular
    AutoCAD, only DIESEL using AutoCAD LT. My only problem thus far with regular
    AutoCAD is running macros containing LT's "_setenv" command.

    For example...

    =======
    ID_LabelLine [La&bel Line]*^C^C_setenv Label \_ucs _ob _nea,_mid \_ai_molc
    _non @ _break _non
    @$M=$(*,$(getvar,textsize),$(+,$(*,$(strlen,$(getenv,label)),.5),.5))<0 _non
    @$(*,$(getvar,textsize),$(+,$(strlen,$(getenv,label)),1))<180 _-insert
    Base/Dwg/Label_2 _non
    @$(*,$(getvar,textsize),$(*,$(+,$(strlen,$(getenv,label)),1),.5))<0
    $(getvar,textsize)
    $(getenv,label);$(if,$(or,$(<,$(index,0,$(getvar,ucsxdir)),0),$(<,$(index,1,
    $(getvar,ucsydir)),0),$(=,$(index,1,$(getvar,ucsxdir)),-1)),_rotate _l _non
    @ 180 )_ucs _r md
    =======

    This single macro above labels a line with an attributed block named
    "Label_2" using the line's UCS for orientation, and then resets the UCS (to
    "md" in this case). You can even use multiple words using quotes.

    Example:
    =======
    Command: _SETENV Enter variable name: Label Value <Mark>: "Paul Turvill"
    Select object to align UCS: _nea,_mid of

    Select line at "x":
    -----------------x----------------

    Result:
    --------- Paul Turvill --------


    This LT macro works PERFECTLY in regular AutoCAD if only I remove the first
    part: "_setenv Label \" which specifies the label value (after manually
    entering a Registry value). I can also substitue "setenv" with "users1" and
    all "$(getenv,label)" with "$(getvar,users1)" and it works perfectly.

    However, using Users1, the value isn't saved and the prompt is a generic:

    Using USERS1:
    "Enter new value for USERS1, or . for none <"Mark">:"

    - istead of -

    Using LT's SETENV command:
    "Enter variable name: Label Value <Mark>:"


    It's that "_setenv" that's just KILLING me! :-( What I'm wondering is
    should I take a crash course in AutoLISP and attempt to create LT's SETENV
    comand for AutoCAD or is there another regular AutoCAD command that I can
    use instead of Setenv? Would it even be possible to create this LT command
    for AutoCAD or would it be worth the trouble? If you think it's possible,
    I'll go for it. I don't know enough about regular AutoCAD (yet) to know if
    something like this is even possible with LISP or any other supported
    programming language.

    Again, using Users1 instead of Setenv does work with no other modifications,
    it's just not ideal.
     
    Mark Gonzales, Feb 18, 2004
    #4
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.