Jump to content

Recommended Posts

Posted

Is it possible to save a string var in a dwg that can be called with diesel?

I now use USERS1, but I need to re-define it everytime I open the dwg...

 

Thanks

  • Replies 21
  • Created
  • Last Reply

Top Posters In This Topic

  • chulse

    8

  • Se7en

    6

  • Lee Mac

    6

  • alanjt

    2

Top Posters In This Topic

Posted

Thanks Lee,

could a reactor be used to hold a string var in a dwg after close/re-open?

vl-propagate wouldn't work after close/re-open would it?

Posted

vl-propagate will transfer a variable to all open drawings (all namespaces), so this would work if you always had a drawing open.

 

A reactor (persistent) would be able to set a variable upon opening a drawing, so the variable would so much be "stored".

 

You could use the xdata of an object to actually store your variable in a drawing. :thumbsup:

 

Lee

Posted

Could I trouble you for an example of those methods please?

 

I have no experience with reactors nor do I know how you would call the xdata with a diesel exp.

 

Thanks!

Posted

You can set XData in an object using the following code:

 

[b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] putxdat [b][color=RED]([/color][/b]Obj App Data [b][color=BLUE]/[/color][/b] ent type1 valeur[b][color=RED])[/color][/b]

 [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] xtype
   [b][color=RED]([/color][/b][b][color=BLUE]vlax-make-variant[/color][/b]
     [b][color=RED]([/color][/b][b][color=BLUE]vlax-safearray-fill[/color][/b]
       [b][color=RED]([/color][/b][b][color=BLUE]vlax-make-safearray[/color][/b]
         [color=Blue][b]vlax-vbInteger[/b][/color] [b][color=DARKRED]'[/color][/b][b][color=RED]([/color][/b][b][color=#009900]0[/color][/b] . [b][color=#009900]1[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=RED]([/color][/b][b][color=#009900]1001[/color][/b] [b][color=#009900]1000[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]

 [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] xval
   [b][color=RED]([/color][/b][b][color=BLUE]vlax-make-variant[/color][/b]
     [b][color=RED]([/color][/b][b][color=BLUE]vlax-safearray-fill[/color][/b]
       [b][color=RED]([/color][/b][b][color=BLUE]vlax-make-safearray[/color][/b]
         [color=Blue][b]vlax-vbVariant[/b][/color] [b][color=DARKRED]'[/color][/b][b][color=RED]([/color][/b][b][color=#009900]0[/color][/b] . [b][color=#009900]1[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]list[/color][/b] App Data[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]

 [b][color=RED]([/color][/b][b][color=BLUE]vla-setXData[/color][/b] Obj xtype xval[b][color=RED])[/color][/b][b][color=RED])[/color][/b]

 

You will need to supply the above with a VLA-Object, Valid Application String, and the data.

 

As for the reactor, I shall look at providing an example for you :)

Posted

If you were going with a reactor, investigate the vlr-dwg-reactor, and either of these callbacks:

 

:vlr-beginDwgOpen

:vlr-EndDwgOpen

:vlr-dwgFileOpened

 

Lee

Posted

Could that be imbedded in a specific dwg to set the USERS1 var each time it's opened?

Posted

I've never done it personally, but in theory, yes you could make a persistent reactor in a drawing to set the USERS1 variable.

Posted

Be careful. I toyed with the idea of a persistent reactor once or twice way back when and i wasnt all that enthused about using it on production drawings.

 

BTW, whats wrong with the "acad.lsp" (thats not the name of the stupid thing but im just too lazy today to care or even look it up)?

Posted
Be careful. I toyed with the idea of a persistent reactor once or twice way back when and i wasnt all that enthused about using it on production drawings.

 

BTW, whats wrong with the "acad.lsp" (thats not the name of the stupid thing but im just too lazy today to care or even look it up)?

 

Good idea Se7en, that would be a much better solution if the purpose of the variable was only for in-house routines.

 

Chulse, check out the ACADDOC.lsp (the file that loads every time a drawing is opened), and maybe include a line (setvar "USERS1"...

 

If you haven't got an ACADDOC.lsp file, you can create one yourself.

 

Lee

Posted

I was really looking for a way to save a single string to a variable in ONLY 1 dwg and have it stay there (like the USERI and USERR variables are)...

I don't want to set it in every dwg I open... as would be the case if I use ACAD.lsp or ACADDOC.lsp.

This is looking way over my head. I might nee to just use a text object and call that with the diesel script...

 

Thanks all

Posted

...If all you want is a string then why dont you just use a text file?

Whats with the Diesel (Are we talking about a toolbar button or something?)

 

Im so lost as to what you want to accomplish. Why dont you describe your needs, goals, and steps you think you need to accomplish them. don't worry about the code; i have a buddy who has a buddy who can peg a fly at 500 yards with a parentheses.

Posted
Good idea Se7en, that would be a much better solution if the purpose of the variable was only for in-house routines.

 

no problem; I'm the king of KISS (Keeping it Stupid Simple).

Posted
...If all you want is a string then why dont you just use a text file?

Whats with the Diesel (Are we talking about a toolbar button or something?)

 

Im so lost as to what you want to accomplish. Why dont you describe your needs, goals, and steps you think you need to accomplish them. don't worry about the code; i have a buddy who has a buddy who can peg a fly at 500 yards with a parentheses.

 

Nice...

 

 

Sorry for not explaining more. First, I'm a programming noob - so be gentle.

 

I used USERS1 to hold my sheet name prefix (TP-) and called it with diesel in fields along with the CTAB variable to manipulate sheet names in title blocks and matchline lables. I managed to automate all of that and if the prefix changes, it will be easy to ubdate with the variable. I was looking for a way to have the prefix variable saved in the dwg so I don't need to set it each time I open the dwg.

Rather simple I'm sure.

I think I could use a text object in the future to hold the prefix string and call that with the field. Probably simpler than the variable...

Posted

heh, i guess it sucks to be you 'cause im never nice.

 

Whats your drawing naming convention (Is there anywhere else you can obtain this information -i.e. why duplicate information if you can harvest it from somewhere?)

Posted

what about a dictionary?

isn't that stored within the drawing?

Posted

hold on there big shooter; lets see if there is anything easy first.

Posted
heh, i guess it sucks to be you 'cause im never nice.

 

Whats your drawing naming convention (Is there anywhere else you can obtain this information -i.e. why duplicate information if you can harvest it from somewhere?)

 

That depends... we do work for other firms and typically conform to their standards ( I have had to learn more sets of standards than you would believe...). In this case we are not sure yet what it will be. I expect a text prefix (like "TP" or "L-") followed by a number. I use CTAB to get the layout tab number.

I do not already have the text for it anywhere else in the dwg - I had planned to set it with SETVAR.

Posted

Ok, so we use the `USERS#' var then.

 

Look up "ACADLSPASDOC" in the help files and let me know if its set or not.

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