Jump to content

Recommended Posts

Posted

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

Posted

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

Posted

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

Posted

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.

Posted
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.

Posted
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.

Posted
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.

Posted

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.

Posted

in fact, looking more closely you have your location and text height answers the wrong way round too so you are supplying 0.25 in answer to location.

Posted

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.

Posted

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

Posted

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!! :$

Posted

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.

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...