Community
AutoCAD LT Forum
Welcome to Autodesk’s AutoCAD LT Forums. Share your knowledge, ask questions, and explore popular AutoCAD LT topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

DIESEL - setenv with a space in the middle?

2 REPLIES 2
Reply
Message 1 of 3
Anonymous
827 Views, 2 Replies

DIESEL - setenv with a space in the middle?

I'm trying to create an auto-numbering DIESEL script with a twist... I have an object which is essentially a label, and one of its many attributes might look something like:

INPUT 4

or:

OUTPUT 7

or, essentially an arbitrary string followed by an arbitrary number.

I'm trying to make the DIESEL script insert a block with that string in the attribute, and then increment the last number in the string, and update an environmental variable with the modified string. The problem I'm running into is that the space between the string and the number keeps screwing up the setenv command (terminating it prematurely). I know that when I'm manually entering a value for SETENV, if I put a quote before the value then it will ignore any spaces and not terminate the command. I'm not sure how to do this in a diesel expression... Here's the snippet of code from the macro that is trying to increment the number and set the variable (which I'm calling DESC right now):

SETENV;
DESC;
$M=$(SUBSTR,$(GETENV,DESC),1,$(-,$(STRLEN,$(GETENV,DESC)),1))$(+,1,$(SUBSTR,$(GETENV,DESC),$(STRLEN,$(GETENV,DESC))))


The result in the command window is:

Command: SETENV
Enter variable name: DESC
Value : INPUT

Command: 5 Unknown command "5". Press F1 for help.

Any suggestions?

Thanks in advance...
2 REPLIES 2
Message 2 of 3
Anonymous
in reply to: Anonymous

>>>...the space between the string and the number keeps screwing up the
>>>setenv command (terminating it prematurely)..<<<

A space in a macro is read as an : in some command sequences, that
ends the command or the entry. This behavior cannot be changed.

Post your entire code for a review, the snippet is missing a key component.

--
Dean Saadallah
http://LTisACAD.blogspot.com
--
Message 3 of 3
Anonymous
in reply to: Anonymous

Thanks for the response. The behavior of SETENV can be changed during manual entry by surrounding the string in quotes. Is there no way to emulate this in DIESEL? Below is the full code:

^C^C_ID;
\-INSERT;
"Z:/DEPARTMENTS/Engineering/Master Block Library/Functional/Tags/TAG-OUT.dwg";
$M=$(GETVAR,LASTPOINT);;;;
L1-$(GETVAR,USERI1); <--inputs the first block attribute
$(GETENV,DEVNUM); <--inputs the second block attribute
$(GETENV,DESC); <--inputs the third block attribute
SETVAR;
USERI1;
$(+,1,$(GETVAR,USERI1)); <--increments the variable for the first block attribute (for next time this macro is called)
SETENV;
DESC;
$(SUBSTR,$(GETENV,DESC),1,$(-,$(STRLEN,$(GETENV,DESC)),1))$(+,1,$(SUBSTR,$(GETENV,DESC),$(STRLEN,$(GETENV,DESC)))) <--increments the last character of the variable for the third block attribute (for next time this macro is called)


The problem is with the variable which stores the third block attribute. It's default initial value would be something like "INPUT 2", and the space in the string is prematurely terminating the SETENV command. I can cut and paste the same line of code into MODEMACRO, and I get the results I want, so the code is correct. I just need a way to get the same string into SETENV (possibly by somehow enclosing it in quotes).

Thanks

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost