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.

persistent scratch variables

Started by bdeck, March 07, 2015, 12:34:46 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

bdeck

Is there any way to attach a persistent scratch variable to a drawing file, rather than put it in a sysexXXX.ini file.

If not, there should be.

Also, the variables should be identifiable by unique names assigned by a macro, and not just by indices to prebuilt arrays, as in the sysex files.

That way one macro would be unlikely to walk on the variable space of another.

bd

prl

Bd, you could put some micro text holding the variable name and value combo, example Bolt3Count=23, on some hidden and reserved layer that is always off layer, say 1999.  Then your basiccad routine would search and parse only the text on that layer for the variable name and appropriate scratch variable value.

prl

Another possibility, remember all entities can have a "Name" which is just a string.  sys$(300).  You could create a junk entity, say a line, or pointmark, or anything  on layer 1999 and have that "name" string contain all your values say separated by commas, or white space, etc.

prl

Another possibility, assuming you don't use many layers, is simply to use hidden layer names to store your string.  So if you had 50 special variables, you would have 50 special named layers, say always from 1901 to 1950,

Example:

your variable is Bolt3Count with a value of 23.    So you create a layer, say 1901, named Bolt3Count=23.  Your basiccad creates and looks for the special values while only cycling the layer names from 1901 to 1950. 


bdeck


prl,

I had thought that  maybe using sysex$() to hold a variable name. whose index could then be used to find the variable value in sysex() would work. The dcd file name could be added to the variable name sysex$() holder. That would work, but the data would not travel with the file, as in your examples.

Now you've got me thinking. How's this....?  Rather than hidden layers or hidden entities, perhaps a uniquely named uninstantiated block could be used to hold variable data in string form or as drawing entities having measurable dimensions. And all without fear of stepping on anyones toes.

Its crazy but it just might work....

Thanks,

bd

prl

Quote from: bdeck on March 07, 2015, 02:27:17 AM
perhaps a uniquely named uninstantiated block could be used to hold variable data in string form . . . without fear of stepping on anyones toes.

bd,  very creative!  I just tried it.  Seems to work for me.  I'll stick that in my tricks bag.

bdeck

#6
Prl,

How did you do it?
I've been playing around with v 23, and cannot seem to suppress the block-insert dialog using sys(36).
Had planned to just insert the exploded block, query the text or entity values, then delete. Not so simple.

bd

EDIT:
Aha, I had neglected to use the special block insertion parameter:
<WaitForOK w - optionally displays the dialog box   [0=no, 1=yes]

Set parameter to zero, all is well,  .... but wait...
Attempt to insert a nonexistent block causes insertion of the most recently inserted block.
Must check  block for authenticity after insertion. 
Also must set sys(36) = 1 or 2  to suppress error message if no blocks exist at all.

dcadRob

#7
You can save info in User Notes (the text block which appears in 'drawing info')

Access in BasicCad with :

>SaveUserNotes
>LoadUserNotes

http://forum.designcad.com/index.php?topic=1237.msg6210#msg6210

prl

Forgot about this.  Apparently you can store a fair amount, although you can't get to the "User Notes" data directly from within BasicCAD.  Using BasicCAD you need to save to disk and read the data back in.  Did I get this right?

dcadRob

Sort of right. The commands that move the notes to and from the DCD file are basicCAD commands but there is no OLE access.

Procedure : Dump the notes to a text file. Read the file. Manipulate the text. Write out a text file. Load the text file into notes.

All of that can be done in basicCAD.

bdeck

dcadRob,

Thanks for the link. Had not seen that.
Informal options abound.

Regards,
bd

prl

#11
Hmm, looked into dcadRob's comment.  I dislike having to write to disk and reading back just to get to the data.

Another option I've been playing with is using attributes.  They can easily be seen or hidden sys(21) and you can store both string text (say for variable name) and numeric value (put the numeric data in the angle or text size properties or both for two values), plus you have an additional string field, sys$(300).

It would let you do something like this which emulates OOP programming concepts.

Have the text field contain "Door" and then

Door.Width (put the width data in the text size)
Door.Height (put the height data in the angle size)

And since it is an entity, you can easily select them all (without processing the entire drawing database) by using >EntitySelect and only processing attributes.  Do some flagging with "text" content and say a color or layer, and you can quickly locate your stored variable data.

bdeck

#12
Hi Prl,

User notes not the best solution for this application, but good info to have.

Cool use of the extra text field in the attributes.

I had taken a look at attributes also, but could not find any use for them unless they are included in a block.

What I like about blocks for this application is that information in blocks can be stored and retrieved by name without affecting the drawing or the selection set.  To retrieve, just archive sys(9), insert the exploded block, query the new entity(s), then eraselast until sys(9) is correct again.

Is it possible to query the attributes in a block without first exploding the block?

bd

EDIT:

Aha, yes it is, using these parameters..

SY_ATTDEFCOUNT
SY_ATTDEFTAG
SY_ATTDEFVALUE

Big improvement. Thanks.

bdeck

Well, on further review, while data from attributes in blocks can be read simply without disrupting the selection set, putting the attribute(s) into the block is a bit trickier, but but not impossible.

One way to do it is to open a new drawing ( >New{} ), create the attribute(s) and block in the new drawing, select the block, copy it to the clipboard, close the new drawing, and paste the block into the original drawing without selecting it. Then eraselast.

That leaves an uninstantiated block in memory as part of the original drawing file, and the original selection set is still in tact.

bd





paulerens

BD,
I'm a little late, but this is a good ide.