Results 1 to 8 of 8

Thread: CUI Macro with Diesel Expression

  1. #1
    Member
    Join Date
    2013-04
    Location
    Northern, IL
    Posts
    10
    Login to Give a bone
    0

    Default CUI Macro with Diesel Expression

    I'm attempting to make a macro / toolbar button which will initiate the offset command and set the offset based on cannoscale.

    Code:
    ^C^C^Roffset;$M=$(if,$(=,$(getvar,cannoscale),"1/32" = 1'-0""),24”,(if,$(=,$(getvar,cannoscale),"1/16" = 1'-0""),12”,(if,$(=,$(getvar,cannoscale),"1/8" = 1'-0""),6”,(if,$(=,$(getvar,cannoscale),"1/4" = 1'-0""),3”,1")
    Gives me this result.

    Code:
    Command: offset
    Current settings: Erase source=No  Layer=Source  OFFSETGAPTYPE=0
    Specify offset distance or [Through/Erase/Layer] <Through>: $M==
    Requires numeric distance, two points, or option keyword.
    I guess the first question is, is it possible to create an IF statement where the "false" is another diesel expression?

    thanks
    --c

    Sidenote, I don't recall choosing a forum name? Is there a way to change it?

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

    Default Re: CUI Macro with Diesel Expression

    Using " in a macro or lisp is problematic at best. CANNOSCALE is just for display, the system variable CANNOSCALEVALUE would work better and avoid having to use ". OFFSETDIST is the system variable for offset distance. 24" is not the same as 24”, again better off using 2 or 24 depending on your units rather than using ".

  3. #3
    Member
    Join Date
    2013-04
    Location
    Northern, IL
    Posts
    10
    Login to Give a bone
    0

    Default Re: CUI Macro with Diesel Expression

    Thanks, did not know about that variable. Also I'm going to try and do some math to mathmagically factor the CANNOSCALEVALUE to the number I need as I don't think I can stack if statements within Diesel? I could be wrong.

    Right now we are taking the scale factor (1 / 32 (32*12 = 384) then dividing it by 16. On a CANNOSCALE of 1/32" = 1'-0" we would offset 24 units(inches).

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

    Default Re: CUI Macro with Diesel Expression

    My menu macro to show Multiline Justification:
    Code:
     $(eval,Multiline Justification = $(if,$(=,$(getvar,cmljust),0),"Top",$(if,$(=,$(getvar,cmljust),1),"Middle",$(if,$(=,$(getvar,cmljust),2),"Bottom"))))
    I think you can create an IF statement where the "false" is another diesel expression, but if you cant there are other ways.

  5. #5
    Member
    Join Date
    2013-04
    Location
    Northern, IL
    Posts
    10
    Login to Give a bone
    0

    Default Re: CUI Macro with Diesel Expression

    Thanks again,

    Code:
    ^C^C^Roffset;$M=$(if,$(=,$(getvar,cannoscalevalue),0.005208333),12,$M=$(if,$(=,$(getvar,cannoscalevalue),0.010416667),6,$M=$(if,$(=,$(getvar,cannoscalevalue),0.020833333),3,$M=$(if,$(=,$(getvar,cannoscalevalue),0.041666667),1.5,1))))
    It appears diesel expressions max out at 4 variables within a macro, this will cover 99% of our drawings but as always a dynamic solution is ideal. I think the next thing is figure out how AutoCAD determines CANNOSCALEVALUE. At the end of the day they are computing 1 / (ScaleFactor * 12). I wish there was a CANNOSCALEFACTOR variable or something similar.

  6. #6
    Member
    Join Date
    2013-04
    Location
    Northern, IL
    Posts
    10
    Login to Give a bone
    0

    Default Re: CUI Macro with Diesel Expression

    Thanks for everything Tom, over lunch a co-worker helped solve the rest of this problem.

    If I take 1/(CANNOSCALEVALUE x 16) I get the desired offset, the button is now dynamic with no more if statements.

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

    Default Re: CUI Macro with Diesel Expression

    Good to hear! I don't use architectual units, so couldn't help with the calculation.

  8. #8
    Member
    Join Date
    2013-04
    Location
    Northern, IL
    Posts
    10
    Login to Give a bone
    0

    Default Re: CUI Macro with Diesel Expression

    For posterity and future reference

    Code:
    ^C^C^Roffset;$M=$(/, 1, $(*, $(getvar,cannoscalevalue), 16))

Similar Threads

  1. Comparing tab name with expression in diesel
    By Phil Gravel in forum AutoCAD Customization
    Replies: 1
    Last Post: 2012-10-31, 07:46 PM
  2. Using a Diesel expression in a macro
    By barker_anthony in forum AutoCAD Customization
    Replies: 3
    Last Post: 2010-10-28, 06:16 PM
  3. Diesel expression with no extension name and Uppercase
    By kheajohn in forum AutoCAD Fields
    Replies: 3
    Last Post: 2008-11-03, 12:07 PM
  4. Backslash in DIESEL expression?
    By christopherd in forum AutoCAD Customization
    Replies: 0
    Last Post: 2007-11-16, 08:17 AM

Tags for this Thread

Posting Permissions

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