chulse Posted August 7, 2009 Posted August 7, 2009 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 Quote
Lee Mac Posted August 8, 2009 Posted August 8, 2009 This may help somewhat: http://www.cadtutor.net/forum/showthread.php?t=38502 Lee Quote
chulse Posted August 10, 2009 Author Posted August 10, 2009 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? Quote
Lee Mac Posted August 10, 2009 Posted August 10, 2009 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. Lee Quote
chulse Posted August 10, 2009 Author Posted August 10, 2009 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! Quote
Lee Mac Posted August 10, 2009 Posted August 10, 2009 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 Quote
Lee Mac Posted August 10, 2009 Posted August 10, 2009 If you were going with a reactor, investigate the vlr-dwg-reactor, and either of these callbacks: :vlr-beginDwgOpen :vlr-EndDwgOpen :vlr-dwgFileOpened Lee Quote
chulse Posted August 10, 2009 Author Posted August 10, 2009 Could that be imbedded in a specific dwg to set the USERS1 var each time it's opened? Quote
Lee Mac Posted August 10, 2009 Posted August 10, 2009 I've never done it personally, but in theory, yes you could make a persistent reactor in a drawing to set the USERS1 variable. Quote
Se7en Posted August 10, 2009 Posted August 10, 2009 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)? Quote
Lee Mac Posted August 10, 2009 Posted August 10, 2009 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 Quote
chulse Posted August 10, 2009 Author Posted August 10, 2009 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 Quote
Se7en Posted August 10, 2009 Posted August 10, 2009 ...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. Quote
Se7en Posted August 10, 2009 Posted August 10, 2009 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). Quote
chulse Posted August 10, 2009 Author Posted August 10, 2009 ...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... Quote
Se7en Posted August 10, 2009 Posted August 10, 2009 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?) Quote
alanjt Posted August 10, 2009 Posted August 10, 2009 what about a dictionary? isn't that stored within the drawing? Quote
Se7en Posted August 10, 2009 Posted August 10, 2009 hold on there big shooter; lets see if there is anything easy first. Quote
chulse Posted August 10, 2009 Author Posted August 10, 2009 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. Quote
Se7en Posted August 10, 2009 Posted August 10, 2009 Ok, so we use the `USERS#' var then. Look up "ACADLSPASDOC" in the help files and let me know if its set or not. Quote
Recommended Posts
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.