Community
AutoCAD Forum
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Ending script command lines using Excel

10 REPLIES 10
SOLVED
Reply
Message 1 of 11
orders3
1536 Views, 10 Replies

Ending script command lines using Excel

You are probably not a fan of using Excel to generate AutoCAD script, But please provide some guidance for the following.

 

I am having great difficulty executing two consecutive commands pasted to the AutoCAD command line. I assume there is a need to escape/terminate the first command before executing the second command.

For example: See details below)
If I cut & paste cell B3 to AutoCAD it sets the text style to style4 as expected.
If I cut & paste cell B4 to AutoCAD it prints the text correctly.
But If I cut & paste cell B6 (concatenated B3 & B4) to AutoCAD it fails.

 

I have tried terminating the style command with semicolon, carriage returns, spaces, etc. without success. I am able to draw lines, print some text, etc. correctly, using innovative characters between commands, but not sure if that is the most efficient technique.

FYI - The program utilizes survey data to plot boundary lines. etc. - N 7° 35' 32'' E.

Any help greatly appreciated.

 

Excel....
Cell B3 ="textstyle"&" "&"style4"
Cell B4 ="-Text"&" "&"20,30"&" "&25&" "&"My text here"
Cell B5
Cell B6 =B3&B4

 

Copy & Paste Cell B3 (Works)
AutoCAD response:
  Command: textstyle
  Enter new value for TEXTSTYLE <"style4">: style4

 

Copy & Paste Cell B4 (Works) - Displays text correctly
AutoCAD response:
  Current text style: "style4" Text height: 4.0000 Annotative: No Justify: Left
  Specify start point of text or [Justify/Style]: 20,30
  Specify rotation angle of text <25>: 25
  Enter text: My text here

 

Copy & Paste Cell B6 (Fails)
AutoCAD response:
  Command: textstyle
  Enter new value for TEXTSTYLE <"style4">: style4-Text 20,30 25 My text here
  Cannot set TEXTSTYLE to that value.
  *Invalid*

10 REPLIES 10
Message 2 of 11
Alfred.NESWADBA
in reply to: orders3

Hi,

 

a textstyle name can contain spaces, so as long as you only paste the content of B3 AutoCAD sends the last <ENTER> automatically.

 

But when you send a string like you have shown in cell B6:

_TEXTSTYLE<ENTER>

STYLE4 TEXT...

AutoCAD does not know that the name of the textstyle ends after the "4" in the string, it looks for a textstyle with the name "STYLE4 TEXT..." and does not find it.

 

You need to send an <ENTER> after the name of the style before starting the next command
So what you need for cell B6 is

Cell B6 =B3 & ZEICHEN(13) & B4

Wheras "ZEICHEN(13)" is for the German version of Excel a control character for <ENTER>, but for that I'm sorry now not to have an English version of Excel and so don't know the English function name exactly, please try

Cell B6 =B3 & CHAR(13) & B4

Cell B6 =B3 & CHR(13) & B4

 

Hope any of these 2 versions is correct and working for you.

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2024
------------------------------------------------------------------------------------

(not an Autodesk consultant)
Message 3 of 11
orders3
in reply to: Alfred.NESWADBA

Thanks for suggestion.  I agree with theory, but no matter where I insert Enter (char(13) it still does not work.

Message 4 of 11
Alfred.NESWADBA
in reply to: orders3

Hi,

 

for me it worked ... can you please upload the XLS-file?

 

[EDIT]... as well as a screenshot of the command line after you run that script [/EDIT]

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2024
------------------------------------------------------------------------------------

(not an Autodesk consultant)
Message 5 of 11
orders3
in reply to: Alfred.NESWADBA

Note - using AutoCAD 2017

It does work for me if the text stile is already set to "style4". But if the text style if not set to style4 than it fails.
Script from Excel.............
textstyle style4

-Text 20,30 25 My text here

Combined....
"textstyle style4

-Text 20,30 25 My text here"

Don't know how to upload xlsx file

 

Screenshot

Set Style Problem.jpg

 

 

Message 6 of 11
Alfred.NESWADBA
in reply to: orders3

Hi,

 

>> Don't know how to upload xlsx file

Make a ZIP of that and use the attachment button below of the textbox in the forum reply.

 

20190831_235350_0001.png

 

From what I see in the screenshot you are sending the quotes (") to the command-line, these are not correct.

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2024
------------------------------------------------------------------------------------

(not an Autodesk consultant)
Message 7 of 11
orders3
in reply to: Alfred.NESWADBA

Agreed, Trying to figure out how they get there.  Perhaps a flaw in Excel

Message 8 of 11
PatrickByrne
in reply to: orders3

Anytime we want to use excel for creating script routines we copy/paste from Excel into Notepad, this gets rid of all formatting and you now have the choice to save it as a script file and import it in AutoCAD or copy/paste from Notepad directly into AutoCAD.


For example the client gives us a list of his drawing numbers which we have to add to the title block, we can create a script in Excel copy/paste this into Notepad and save it as a script routine. This script will open each drawing and update the title block. It also means you are going to see the list of commands that will appear in AutoCAD.

 

Patrick

http://www.multi-batch.com/

For your entire batch processing needs

Message 9 of 11
orders3
in reply to: PatrickByrne

Patrick's Notepad solution above work and is a great solution.  In Notepad you can see the exact script you are pasting.  Also, you can remove any extraneous characters that Excel  may insert. -Thanks Patrick

 

I have abandoned the "textsyle" approach and  used a style setting that does not set the height , text style "standard, etc.  Then you can set the height in each text command.  Example below.

Thanks all for your responses.

 

Cell B3 =" "&CHAR(13)&"-Text"&" "&"20,60"&" "&"1" &" "&45&" "&"My text 1"
Cell B4 =" "&CHAR(13)&"-Text"&" "&"25,50"&" "&"2" &" "&45&" "&"My text 2"
Cell B5 =" "&CHAR(13)&"-Text"&" "&"30,40"&" "&"3" &" "&45&" "&"My text 3"
Cell B6 =" "&CHAR(13)&"-Text"&" "&"35,30"&" "&"4" &" "&45&" "&"My text 4"
Cell B7
Cell B8 =B3&B4&B5&B6&CHAR(13)

Message 10 of 11
orders3
in reply to: PatrickByrne

Patrick's Notepad solution work great.  And you can see the exact script you are pasting and if required remove any Excel extraneous characters.  Thanks Patrick and all other responses.

 

I abandoned the "textstyle" approach and am using a style that does not set the height ("standard", etc).  Then you can set the height, rotation, etc. in each Text command.  Example follows:

 

Cell B3 =" "&CHAR(13)&"-Text"&" "&"20,60"&" "&"1" &" "&45&" "&"My text 1"
Cell B4 =" "&CHAR(13)&"-Text"&" "&"25,50"&" "&"2" &" "&45&" "&"My text 2"
Cell B5 =" "&CHAR(13)&"-Text"&" "&"30,40"&" "&"3" &" "&45&" "&"My text 3"
Cell B6 =" "&CHAR(13)&"-Text"&" "&"35,30"&" "&"4" &" "&45&" "&"My text 4"
Cell B7
Cell B8 =B3&B4&B5&B6&CHAR(13)

Message 11 of 11
PatrickByrne
in reply to: orders3

Glad you found it helpful, Notepad is great for getting rid of formatting done in another program, for example copying notes from Microsoft Word to AutoCAD

Patrick
http://www.multi-batch.com/
For your entire batch processing needs

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

Post to forums  

Forma Design Contest


Autodesk Design & Make Report