DesignCAD 3D Max 2027 box
Now available

DesignCAD 2027

Hatches that follow their boundaries, an on-screen dial to turn your model, and a way to find any command by name, in a clean Windows 11 look.

Macro writers needed to build Configuration Save macro

Started by Lar, April 09, 2010, 09:58:44 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Lar

***Edit 12 April 2010: The macro dissused in this post has been completed by myself and is now undergoing testing***

**Last Edit to remainder of post: 10 April 2010**
Hi all,

There's a lot of demand on the forum for a way to save all the configurations of each drawing file. A macro for this would not be difficult to write except that there are lots and lots of sys functions. I propose we get together and write it ourselves. I have done the preliminary stuff (like saving the filename) and the first 20 sys functions (not all of them are necessary). I suggest that each reply first states the range of sys functions they will do. After they have done it externally they come back, edit the reply and paste their portion in the same reply. Each subsequent reply should do a range following the previous reply so we don't have to go back searching for gaps in the full set.

You would need the sys functions text file to do this. All you have to do is copy the following line and type in the relevant number in both sets of brackets. Both brackets in each line must have the same number.

print #1, "sys()=",sys()       '

The apostrophe at the end is for comments. Not all functions are necessary and the read only ones should not be included.

The potential for mistakes is big here so each contributor should check their set thoroughly before pasting in. Maybe each contributor should check the set that follows his. As sets get done we can each just copy and paste to our own master file. Anybody else noticing mistakes should report them.

Any sys function for a particular version and above should be noted in the following format, above the actual line, so users of lower versions can use his search function to find such lines and put an apostrophe before them so they don't run:

'*****Version ## or higher...    'replace ## with the actual version number, of course...

When a set is pasted in the author should preview it in case a smiley face is generated. If so , just put a space before and after the number in the brackets.

I suggest each contributor tags his name, just in case...

If all goes well you will be able to run this macro in a drawing whose configuration you wish to save. This macro will write another macro that you will name. The name you give will be prefixed by "Config_" (each user can change this individually). When you open the drawing again run the 2nd macro and all the configs will be restored.

Lar

'*****MacroStart*****
'Config Save.d3m
'by DesignCAD community   (hopefully)
'Started 9 April 2010

'****************************************
precision 8      'each person can set their own value here
'****************************************
sys(36)=1   'silent mode on, just in case.

'NAME FILE...
fname:
input "Enter name for new file (will be prefixed with Config_)..." nm$
if sys(999) then end   'end macro if 'cancel' is clicked...

'IF FILENAME EXISTS...
nufile$ = sys$(24)+"\Config_"+nm$+".d3m"    'sys24 is the default macro folder
 if  exist(nufile$)=1 then
  input "File name exists. 1=overwrite; 2=rename; 3=cancel" exis
   if exis=3 then end
   if exis <>1 then goto fname
end if

'IF FILENAME IS INVALID...
  if  exist(nufile$)=-1 then
   input "Name is invalid. 1=rename; 0=cancel" inv
    if inv=1 then goto fname
    if inv=0 then end
end if

'CREATE NEW FILE...
open "o", 1, nufile$
'****************************************
'use the following line, just fill in the sys number in both sets of brackets (ignore 1st apostrophe & spaces, use 2nd apostrophe for comments)...
'      print #1, "sys()=",sys()       '
'****************************************
'sys 1 - 20 by Lar...
print #1, "sys(2)=",sys(2)      'shading mode for active window...needs more work since have to run for each window.
print #1, "sys(4)=",sys(4)       'line type
print #1, "sys(5)=",sys(5)       'line type scale
print #1, "sys(6)=",sys(6)       'line width
print #1, "sys(7)=",sys(7)       'distance precision displayed in the coordinate bar and in dialog boxes. [-7<=x<=15]
print #1, "sys( 8 )=",sys( 8 )       'angular precision displayed in the coordinate bar and in dialog
print #1, "sys(10)=",sys(10)       'units of measurement for printing
print #1, "sys(11)=",sys(11)       'printing scale
print #1, "sys(12)=",sys(12)       'text size
print #1, "sys(13)=",sys(13)       'text angle
print #1, "sys(14)=",sys(14)       'display grid type
print #1, "sys(15)=",sys(15)       'display grid enable/disable *****Version 15 or higher*****
print #1, "sys(16)=",sys(16)       'Enable/Disable Use Plot Range Box
print #1, "sys(17)=",sys(17)       'Snap grid on or off
print #1, "sys(18)=",sys(18)       'Plot point optimization
print #1, "sys(19)=",sys(19)       'Minor Display Grid spacing along x (v16&+) or grid size (v15&-)
print #1, "sys(20)=",sys(20)       'Minor Display Grid Y spacing (or radial for polar grid) (v16&+) or Snap grid size (v15&-)


Dr PR

Lar,

I started making a list of all the user-selectable options in DesignCAD, and the relevant choices, including program defaults. The "File" menu and sub menus made a list more than a dozen pages long, single spaced with one item per line. I gave up. There must be thousands of options! It would take weeks doing nothing else to complete the list.

Are there sys() functions for all the options?
DesignCAD user since 1987

Lar

Doc, I think the sys functions cover the most drawing stuff that differ from one file to another when you close that file, like the current line style, line spacing, which layer you want text and dimensions to go on, the current color, very many of the dimension stuff, etc, etc. Stuff like whether 'Save As' includes 'selected only', '2d mode', 'clean up lines' and 'hidden lines' or whether 'selected only' is active for the parallel command is easy enough to select when you call up that command every now and then. Plus, I'm not sure basiccad would have access to all those functions.

The sys functions number up to 20011 and maybe more but it there are a lot of very big gaps in the numbering. My guess is that there are about 3-400 and we don't need all of those. For example most of the layer functions are already saved with each file, we don't need the minX, Y and Z of the drawing, etc. I'm already thinking that the exact layer status (on/off/locked/unlocked) could be included since I already have that macro written and if entities are selected when you run the macro it will be able to reselect them (and even the previous selection) - might create too big a file though, if thousands, or even hundreds, of entities are selected.

Lar

Rob S


I think you are onto something here, but maybe it could be refined a bit before bulldozing ahead!!!  So, in case anyone is interested, I'm going to ramble on for a bit here.

Does anyone agree that there should maybe be two versions - one for program config, and another for drawing config?

So often I would like to restore my settings for a particular drawing, most importantly the dim settings and text size, etc.  The old dss05 macro did everything I needed, but I need to type in what I want.  Using your system, combined with dss05 inserted in it, or is there an include function in basiccad, so it can run an existing macro from the current one?   If so, you could save and set most of the significant dim and text parameters by writing out and saving only a dozen or so variables from the existing drawing.  I think many of these don't have equivalent sys parameters.

One could conceivably make a macro, assigned to a button, that would load settings of the same name as the drawing filename, and another to save current settings in a config file which includes the drawing filename.

For myself, the rest of the program settings are always left the same, so the macro only needs to know those settings not normally saved with the drawing.  For those who want actual different "program defaults" as opposed to drawing defaults" there could be a separate macro.

Would it not be possible, and maybe more efficient to have a single macro, which reads or writes setting parameters to/from a text file?
User since forever

edgar

Quote from: Lar on April 09, 2010, 09:58:44 PM
I propose we get together and write it ourselves.

I do not mind that we users do the work. I think we should lobby DrollTroll for a comment before we go too far. Just to make sure we are all on the same page, could you attach (or post a link) to the file from which you are deriving the most up-to-date sys information (I have a PDF which is so old it only goes up to sys(803))?

Quote from: Lar on April 09, 2010, 09:58:44 PM
'*****Version 15 or higher...
print #1, "sys(16)=",sys(16)       'Enable/Disable Use Plot Range Box
print #1, "sys(17)=",sys(17)       'Snap grid on or off
print #1, "sys(18)=",sys(18)       'Plot point optimization
print #1, "sys(19)=",sys(19)       'Minor Display Grid spacing along x (v16&+) or grid size (v15&-)
print #1, "sys(20)=",sys(20)       'Minor Display Grid Y spacing (or radial for polar grid) (v16&+) or Snap grid size (v15&-)

I am not sure how the above notation is to be read. Does it mean that:
print #1, "sys(16)=",sys(16)       'Enable/Disable Use Plot Range Box
is for v15 & up, or does it mean that all which follow are v15+?
-Ed

Lar

Edgar,
  it applies to just the line below it. Maybe it should be written:

print #1, "sys(16)=",sys(16)       'Enable/Disable Use Plot Range Box   *****Version 15 or higher*****

...note: I made the change to my starting post...

It's just meant to jump out at the user visually or be written so a search command can find them, where ever they are in the file.

I'll work on attaching a link of my sys file. It'll be good if DT could do this since he would have the most recent.

Rob,
 anything is possible but smart as basiccad is the macro won't write itself. Some poor slob of a human has to get in there and do the writing (which is what God put on this earth for: to be the random factor that fills in the gaps as they pop up. That's why we have free will). What I'm attempting is to save all the relevant sys functions for a drawing at the time of closing so upon opening you can pick up where you left off if, say, you worked on something else in between. If you want generic sets just set up template files and run the macro, naming it 'Template001', etc.

There are a great many sys functions for dimensions and text parameters are covered as well. BasicCAD can run a 2nd macro from within a macro but then you would be stuck with that same macro running all the time. What each of us can do is break out portions of the master macro that we want separately and save as another macro then run those for whatever particular needs we each have.

If you guys want every single command parameter saved for every single drawing I suggest you keep begging 'the suits', as Doc so eloquently put it. Honestly, I don't think it makes sense saving things like 'X Axis' for the mirror command because the next time you use the mirror command you may need 'Y Axis'.

For those whose computers can hibernate just run separate instance of dcad for every project you are working on concurrently, turn off auto-updates (cause that sometimes forces a shut down) and hibernate rather than shut down the computer.

Lar

Rob S

For the version stuff, if the parameter is not applicable, the macro can test for version number at the start of the macro, and run these bits only if it equals or exceeds the required number.

For the list of sys functions I have one for V17 that someone once culled from the help file, and I've noted some of the new ones in a comment at the end.

Lar, you are quite right, if the thing gets working, we can each removee the parts we don't want to bother with from it, etc.

I still think there are a lot of basic program setup features that most people probably set once and never change, so not much need to save and restore all that every time, or provide a separate macro for those things.

Because I work with lots of different scales, and types of drawings, and metric/imperial, I'd be real happy if I can restore most of what hits me when I start editing a drawing - try drawing text, it's the wrong size, draw a dimension, its the wrong scale, or it comes out feet in a metric drawing, etc.
User since forever

Lar

Here's my sys as a text file (I have the ~ in front of the name so it comes up top if I sort by name. I added stuff as DT announced it but never cleaned it up, so here goes...

Lar

Dr PR

Lar,

This is a bit off subject, but I find the idea of "hibernating" with DesignCAD files open really dangerous. In every version of DesignCAD I can recall, after the program has been running for a few hours (when actually being used to edit a drawing) bits and pieces start falling off the program. In earlier versions some keyboard commands stopped working. The the latest versions the Gouraud shading display starts getting screwed up, it forgets the recent zoom history, and commands like Intersect 2 start failing frequently.

Closing the drawing and opening it again usually fixes these problems, but sometimes I have to shut down the program and restart it. Leaving the program/drawing running for long periods through hibernation is just asking for these problems. Turning off the computer eliminates all variable working values and forces a clean restart.
DesignCAD user since 1987

Lar

I hibernate for months at at time. Lately I was having a crashing situation so I've been restarting a lot and I've noticed no difference.

Anyway, this morning I decided to complete the macro myself so I wrote a macro to write the config macro. I just had to pick through the sys numbers to eliminate the unneeded stuff.

In doing that I've noticed that because of the potential for mistakes this could be a very dangerous macro so I'll be doing lots of testing. I probably will not release it for public consumption.

Lar

paulerens

#10
Lar,
How much I would like to believe in the possibility to bring this macro to a conclusion .
If I can be helpful, I would like to cooperate.
But, I think this belongs to the basic program of DesigneCAD
And because there is already a big part in the vicinity of Workspace.
I would rather have DT & Co to interfere.

Paul.

Rob S


Me too, but we've already been waiting quite some time!!

When I get some time and the requisite ambition, I am going to attempt to use the building blocks provided by LAR to make some kind of Macro to save what I consider to be "drawing defaults" .

The trick will be to figure out how to save some of the new parameters for which sys functions do not appear to exist, or are not documented.

User since forever

Lar

Paul, Rob, etc,

I have completed the sys macro myself, leaving out the read_only stuff, things that already get saved with the file (like layer color and layer line style) and non config stuff. I want to test it some though.

I wrote a macro where you enter start and end numbers and it would write the print sys lines with the numbers filled in. I don't have time to upload it now but I could later.

Lar

Lar

Quote from: Rob S on April 11, 2010, 04:41:51 PM
The trick will be to figure out how to save some of the new parameters for which sys functions do not appear to exist, or are not documented.

Rob, could you give me some examples of this?

Lar








/

Rob S

I don't think there are any for the following new parameters

- "AUTO" text placement

- "use different arrows" for extended and baseline dimensions

- V18+ text gap - does sys (43) work for that?

- The new parameters for text offset and baseline offset  <optiondimtextoffset vs <offset

- The "movement" parameters

- dim text "over first" and "over second" extensions

When we did the dss05 macro, I vaguely remember first trying to find sys functions to set for these parameters, and not finding many of them, it seems maybe there aren't that many missing after all.
User since forever