Scripting a hatch - 'New background color'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
More of an observation about a behavioural change than anything else. I've applied a workaround for it. See below.
The problem
I've got an application generating a script that includes hatching of the last object the script created:
-hatch
p
s
t
80
co
252
s
l
When it gets to setting the colour in a new DWG it's asking for a 'New background color'.
Command: -hatch
Current hatch pattern: _SOLID
Specify internal point or [Properties/Select objects/draW boundary/remove Boundaries/Advanced/DRaw order/Origin/ANnotative/hatch COlor/LAyer/Transparency]: p
Enter a pattern name or [?/Solid/User defined/Gradient] <Solid>: s
Current hatch pattern: SOLID
Specify internal point or [Properties/Select objects/draW boundary/remove Boundaries/Advanced/DRaw order/Origin/ANnotative/hatch COlor/LAyer/Transparency]: t
Specify transparency value (0-90) or [. (for use current)] <use current>: 80
Current hatch pattern: SOLID
Specify internal point or [Properties/Select objects/draW boundary/remove Boundaries/Advanced/DRaw order/Origin/ANnotative/hatch COlor/LAyer/Transparency]: co
New color [Truecolor/COlorbook/. (for use current)] <use current>: 252
New background color [Truecolor/COlorbook/. (for none)] <None>: s
A color number or standard color name is required.
New background color [Truecolor/COlorbook/. (for none)] <None>:
Current hatch pattern: SOLID
Specify internal point or [Properties/Select objects/draW boundary/remove Boundaries/Advanced/DRaw order/Origin/ANnotative/hatch COlor/LAyer/Transparency]:
Command:
The script gets stopped here and AutoCAD blinks at me until I've given it an answer.
The next time the script is run, it runs cleanly and will continue to run cleanly in the same drawing.
It's not template based, as I've tried with the basic acad.dwt file supplied with AutoCAD as well as our own template. The behaviour is the same.
I've had a look at the HPBACKGROUNDCOLOR system variable, but even setting that to something before triggering the script sees it asking for a 'New background color'. I can see that it has been set (to green (3) in the sample below), but it still triggers the pause for input.
COlor/LAyer/Transparency]: co
New color [Truecolor/COlorbook/. (for use current)] <use current>: 252
New background color [Truecolor/COlorbook/. (for none)] ❤️ (green)>: s
A color number or standard color name is required.
New background color [Truecolor/COlorbook/. (for none)] ❤️ (green)>:
I can't easily see another variable that affects the behaviour.
To reiterate, it only occurs on the first run in a new drawing and only when scripted. I cannot trigger it by attempting to run -hatch in the command window. When it has had its response once, it's fine in that drawing forever.
My kludged 'fix'
I found that if I set HPCOLOR before hitting the -hatch part of the script and removed the 'co' component, I could avoid the issue.
HPCOLOR
252
-hatch
p
s
t
80
s
l
Clunky but it functions.