I need some help with acaddoc.lsp

I need some help with acaddoc.lsp

Anonymous
Not applicable
1,209 Views
11 Replies
Message 1 of 12

I need some help with acaddoc.lsp

Anonymous
Not applicable

I used to be good at this, but have forgotten a lot.  I want to create a acaddoc.lsp.  I am starting with a couple of easy lines.  Except they won't process in lisp..  They are below, how can I change them to make them work?

 

(setvar "tstacksize" 90)
(setvar "viewres" 20000)

 

Thanks!

0 Likes
Accepted solutions (1)
1,210 Views
11 Replies
Replies (11)
Message 2 of 12

rkmcswain
Mentor
Mentor

Viewres is not a system variable. It's a command.

Plus, you could just set this in your template drawings, as it's saved in the DWG file. No need to try and reset it each time a file is opened. Moreover, with today's graphics cards and the new graphics subsystem in 2015 and later, the viewres setting is not even that important. You can get smooth arcs and circles even with a setting as low as 100.

 

If you still want to do this, use this: (vl-cmdf "._viewres" "_Y" "20000")

Not sure why the first line is not working, it works fine here for me. (It's also saved in the DWG file BTW)

R.K. McSwain     | CADpanacea | on twitter
Message 3 of 12

Kent1Cooper
Consultant
Consultant
Accepted solution

The (setvar) function is for System Variables.  VIEWRES isn't one of those, but a command:

 

(command "_.viewres" "_yes" 20000)

 

There may be a System Variable in which that value is stored, but I couldn't find it quickly.

 

The tstacksize one looks like it ought to work -- if it really doesn't, I don't have any idea why not.

 

 

Kent Cooper, AIA
Message 4 of 12

Anonymous
Not applicable

To: KENT1COOPER

 

Thanks,  that fixed it.  I appreciate the help.  For my knowledge:  What does the underscore represent in front of viewres and y.

 

 (command "_viewres" "_y" 20000)

0 Likes
Message 5 of 12

rkmcswain
Mentor
Mentor
The underscore indicates the command that follows should use the global command name and not the localized command name.

See: http://help.autodesk.com/view/ACD/2016/ENU/?guid=GUID-D991386C-FBAA-4094-9FCB-AADD98ACD3EF

R.K. McSwain     | CADpanacea | on twitter
0 Likes
Message 6 of 12

cadffm
Consultant
Consultant
International call of commands.
(getcname "LINE")
_LINE

But now in German language
(getcname "LINIE")
_LINE
Wow!

If you (please) set Underlines in front of engl. Commandnames and Options, all over the World you (command) works!

It is the way how to use Autocad-commands in automatations (macro,script,lisp and whatever use sendcommands.

Sebastian

0 Likes
Message 7 of 12

Anonymous
Not applicable

Thanks rkmcswain,

 

My template files and drawings I work on are set this way.  I do open drawings, some not from my company, some that others created that don't have these settings.  That's why I want to use this lisp file.

 

I appreciate your help.

 

0 Likes
Message 8 of 12

rkmcswain
Mentor
Mentor
No worries @Anonymous.

Note that if you change the DWG at startup like this, then DBMOD is no longer = 0.

What this means is that when you open any drawing, and immediately close it, (without making any apparent changes) you will be prompted to save.

The same applies to "Drawing 1.dwg" that may open when you start the application. It will no longer close when you open the first named drawing.

Cheers.

R.K. McSwain     | CADpanacea | on twitter
0 Likes
Message 9 of 12

Anonymous
Not applicable

Thanks,  I will look at that.  Appreciate the help.

0 Likes
Message 10 of 12

DannyNL
Advisor
Advisor

Unless you expand your code and store DBMOD before and restore DBMOD to 0 after setting your variables. That way if you only open and close but nothing else, AutoCAD will still consider it like nothing has changed and close the drawing without asking to save it.

 

(acad-push-dbmod)
(command "_.viewres" "_yes" 20000)
(acad-pop-dbmod)
0 Likes
Message 11 of 12

rkmcswain
Mentor
Mentor
@DannyNL - certainly a valid option for some people. But I _do_ want to know when the DWG has been altered at startup.

Cheers

R.K. McSwain     | CADpanacea | on twitter
0 Likes
Message 12 of 12

DannyNL
Advisor
Advisor

@rkmcswain I agree, I also want to know when my drawing has been changed, but in this case arguably nothing really has been changed as the information in the drawing is still the same.

So in example of just opening and closing a drawing where nothing is added/removed from the drawing, this prevents the prompt of saving the drawing which probably covers 99% of these specific cases. In the other 1% you can just click on the save button before closing the drawing.

0 Likes