Jump to content

Script is not running


sunsan

Recommended Posts

Hello

I'm getting frustrating with a script I have to write. I've tried it for many times, but there's no way. When I try to run the script from AutoCAD appears "Enter an option".

Please, please, can someone tell me what I'm doing wrong?

 

The goal is get the text in blue:

 

1.jpg

 

This is what I wrote in the Notepad:

 

;Writteh by:

;

-LAYER

m

Test

c

Blue

s

Test

 

-STYLE

Lab 05-1

 

Verdana

0.25

 

 

 

"Lab 05-1"

TEXT

0.2500

@8.5,3.8

NOTES:

1. ALL DIMENSIONS ARE IN INCHES.

2. MATERIAL STEEL.

3. REMOVE AL ROUGH EDGES

 

 

;

;End of Script

Link to comment
Share on other sites

Comments are ok, you just need to watch the command line history to see what is being asked

When you make the layer color blue it is asking you for the name of the layer to be made blue (Test)

You will find more things like this as you go through your script, the best way to make a script is to run the commands from the command line and write down every single answer to all the prompts (or copy the command line history [F2] to notepad and edit out unwanted bits), it is usually a good idea as well to give a standard answer in stead of just using a line return (makes it much easier to debug or add something later).

Names need to be enclosed in quotes because a space is read as a line return.

You will also need to use the MTEXT command or issue the TEXT command multiple times.

;comments added freely
-LAYER
m
Test
c
Blue
;throughout the script
Test
-STYLE
"Lab 05-1"
Verdana
0.25
1
0
N
N
MTEXT
8.5,3.8
1,1
NOTES:
1. ALL DIMENSIONS ARE IN INCHES.
2. MATERIAL STEEL.
3. REMOVE AL ROUGH EDGES

Link to comment
Share on other sites

Sorry for be offline during the week. SLG210 I have read the Code posting guidelines and tried to edit my first coment but I can't find #...

 

Thank you BIGAL and Steven-g, I've tried both but there's is no way! Everytime I run the script, AutoCAD ask me about the options.

Link to comment
Share on other sites

Sorry for be offline during the week. SLG210 I have read the Code posting guidelines and tried to edit my first coment but I can't find #...

 

Thank you BIGAL and Steven-g, I've tried both but there's is no way! Everytime I run the script, AutoCAD ask me about the options.

 

Select "Edit Post" and then the "Go Advanced" button to the lower right, you'll find the # there.

Link to comment
Share on other sites

Pretty sure can not have comments in a script remove all lines starting with ;

 

also do not need the @ 8.5,3.8 will work

 

Ralph Grabowski in his article "How to Write a Script File" says the following....

 

; (semi-colon).

You probably already noticed that the semi-colon lets me insert comments in a script file. AutoCAD ignores anything following the semi-colon.

Link to comment
Share on other sites

Sorry for be offline during the week. SLG210 I have read the Code posting guidelines and tried to edit my first coment but I can't find #...

 

Thank you BIGAL and Steven-g, I've tried both but there's is no way! Everytime I run the script, AutoCAD ask me about the options.

Can you tell us which options it is asking for? It could be asking to tell it how your day was for all we know.

Link to comment
Share on other sites

one other thing, you appear to be giving your new style a height and then setting the height in the text command, this will not work. Either replace 0.25 with 0 in your style section or remove the 0.25 within the text section.

Link to comment
Share on other sites

Here is what my Test.scr script file looks like.

 

;Test.scr

; This works. How do I know? I tested it before posting.

-LAYER

M

Test

c

Blue

;You can add a comment anywhere as previously stated.

Test

 

-STYLE

Lab_05-1

;I don't think a style name can have a space if entered at the command line.

Verdana

0.25

1

0

N

N

TEXT

8.5,3.8

0

NOTES:

TEXT

 

1. LINE ONE TEXT.

TEXT

 

2. LINE TWO TEXT.

TEXT

 

3. LINE THREE TEXT.

Link to comment
Share on other sites

Thank you! I finally get it. :)

 

 

;Written by:

;This script file creates the object ...

-LAYER

m

Test

c

Blue

Test

S

Test

-STYLE

"Lab 05-1"

Verdana

 

1

0

N

N

MTEXT

8.5,4.0

L

E

0.25

H

0.25

0

"NOTES:

1. ALL DIMENSIONS ARE IN INCHES.

2. MATERIAL STEEL.

3. REMOVE AL ROUGH EDGES"

ZOOM ALL

;

;End of Script

Link to comment
Share on other sites

ReMark, you're right, I tested it many times before posting it too. Anyways, one mistake I've done was having the units on the template in inches, not in metric!! :$

Link to comment
Share on other sites

You're entirely welcomed sunsan. :)

 

In the future when you build your script test it in stages as you go along rather than waiting to the end.

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...