TigerByTheTail Posted September 2, 2009 Posted September 2, 2009 I am using LT 2010, working on cable route drawings. I have a macro that sets two variables WALLSEQ1 and WALLSEQ2 for cable sequential numbers (in meters), and calculates a corresponding cable coil COIL1 (in feet). The sequential readings are in a 4 or 5 digit format, examples 0012 or 01234. I use SETENV to define my cable sequential variables, in order to capture the preceding zeroes. Then I subtract one from the other, and multiply by 3.28084 to convert the coil to feet. My problem is that the coil value is sometimes negative, depending on the sequential numbers. If WALLSEQ1 is larger than WALLSEQ2, the coil is positive, if not then the coil is negative. The coil value is also in decimal format. I need to round it to the nearest whole number. Is there a way to use ABS (absolute) and RND (round) in macros and diesel expressions? If I can't get an absolute value, could an IF statement be used instead? Here is my macro... ^C^Csetenv;WALLSEQ1;\setenv;WALLSEQ2;\setenv;COIL1;$M=$(*,$(-,$(getenv,WALLSEQ1),$(getenv,WALLSEQ2)),3.28084) Quote
rkmcswain Posted September 2, 2009 Posted September 2, 2009 "IF" is a valid DIESEL function. There is no ABS or RND DIESEL functions. Reference: http://docs.autodesk.com/ACD/2010/ENU/AutoCAD%202010%20User%20Documentation/index.html?url=WS73099cc142f4875513fb5cd10c4aa30d6b-7b3c.htm,topicNumber=d0e393837 Quote
TigerByTheTail Posted September 2, 2009 Author Posted September 2, 2009 Thanks rkmcswain. I'll try an IF statement to resolve the negative value. Is there another way to round a number? Quote
TigerByTheTail Posted September 2, 2009 Author Posted September 2, 2009 I found a way to use ABS and ROUND within my macro. I used the 'CAL command when I was setting my COIL1 variable. No need for an IF statement. ^C^Csetenv;WALLSEQ1;\setenv;WALLSEQ2;\setenv;COIL1;'cal;abs(round($M=$(*,$(-,$(getenv,WALLSEQ1),$(getenv,WALLSEQ2)),3.28084))); Quote
rkmcswain Posted September 2, 2009 Posted September 2, 2009 Good one...! I forgot about 'cal being available in LT... Quote
TigerByTheTail Posted September 3, 2009 Author Posted September 3, 2009 Here's the final macro using an IF statement with diesel and 'CAL expressions. ^C^Csetenv;SEQUNITS-F-or-M;\setenv;WALLSEQ1;\setenv;WALLSEQ2;\$M=$(if,$(eq,$(upper,$(getenv,SEQUNITS-F-or-M)),M),setenv;COIL1;'cal;abs(round(3.28084*($(getenv,WALLSEQ1)-$(getenv,WALLSEQ2)))),setenv;COIL1;'cal;abs($(getenv,WALLSEQ1)-$(getenv,WALLSEQ2))); Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.