Assembly Posted December 17, 2009 Share Posted December 17, 2009 Continuing on from previous posts about using CreateCustomObjectN here is a useful menu tool I set up. (Most of the script is cut and paste direct from the documentation). Draw a PIO selected and run the script. It will create a text file with a list of parameter names. These names can be used with SetRField. PROCEDURE TellMeVariables; VAR fileName :STRING; major, minor, maintenance, platform :INTEGER; hRecord:handle; result: Boolean; FUNCTION WriteFieldValues(h :HANDLE) :BOOLEAN; VAR cnt :INTEGER; recHand :HANDLE; recName :STRING; fldName :STRING; BEGIN recName := GetName(GetRecord(h, NumRecords(h))); recHand := GetObject(recName); FOR cnt := 1 TO NumFields(recHand) DO BEGIN fldName := GetFldName(recHand, cnt); WriteLn(fldName); END; END; FUNCTION WriteValuesToParameters(h :HANDLE) :BOOLEAN; VAR cnt :INTEGER; recHand :HANDLE; recName :STRING; fldName :STRING; BEGIN recName := GetName(GetRecord(h, NumRecords(h))); recHand := GetObject(recName); FOR cnt := 1 TO NumFields(recHand) DO BEGIN fldName := GetFldName(recHand, cnt); WriteLn(fldName,' :=p',fldName); END; END; BEGIN GetVersion(major, minor, maintenance, platform); IF platform = 1 THEN BEGIN fileName := '/NewScript.txt'; END ELSE BEGIN fileName := 'C:\NewScript.txt'; END; ReWrite(fileName); result:= WriteFieldValues(hRecord); ForEachObjectInLayer(WriteFieldValues, 2, 0, 4); ForEachObjectInLayer(WriteValuesToParameters, 2, 0, 4); Close(fileName); END; RUN(TellMeVariables); Draw a PIO selected and run the script. It will create a text file with a list of parameter names. These names can be used with SetRField. Example: I wanted to use the elevation benchmark tool inside a PIO. Procedure DrawFrameLevelHeights(xtemp:Real); Begin; objectname:='Elevation Benchmark'; hobject:= CreateCustomObjectN(objectname,-framedepth-50,Head,0,False); SetRField(hobject, objectname,'LineLength',Num2Str(0,xtemp)); SetRField(hobject, objectname,'Title','Lintel: +'); SetRField(hobject, objectname,'UseY','True'); SetRField(hobject, objectname,'Style','US'); SetRField(hobject, objectname,'Orientation','Left'); SetRField(hobject, objectname,'MFact','3'); SetRField(hobject, objectname,'Factor','.75'); Hmove(lNewObj,-xtemp,0); End; I'm thinking the WriteLn function might be a very powerful tool... with it you can write a script to write a script. In the TellMeVariable I included a function that picks up all the parameter names then creates assigns the internal variables to the object parameters. I am just starting to play around with Dialogs- is anyone using WriteLn in scripts to auto generate Dialog Scripts?. If this question make sense and there a couple people interested in seeing how it might be done, I've been looking for a project to give Google Wave a go on- and I have a couple spare invites. Quote Link to comment
Jonathan Pickup Posted December 17, 2009 Share Posted December 17, 2009 i already have google wave, so save your invite, but I'm still interested. Quote Link to comment
Pat Stanford Posted December 17, 2009 Share Posted December 17, 2009 Very nice. I posted something similar to the Vectorscript Resource share forum a while ago. It creates a worksheet instead of a text file. http://techboard.nemetschek.net/ubbthreads/ubbthreads.php?ubb=showflat&Number=108487#Post108487 As for the writeln for dialog boxes, have you take a look at Dialog Creator? http://www.nemetschek.net/community/addons/plugins/dialog_creator.php Quote Link to comment
Miguel Barrera Posted December 17, 2009 Share Posted December 17, 2009 If you want to save time writing to a text file, set a document the way you want to code it in your script (add objects,classes,etc.) and use Export->Vectorscript to save the resulting code to a text file. Look for the object creation section and then copy relevant code into your script. Quote Link to comment
Assembly Posted December 18, 2009 Author Share Posted December 18, 2009 If you want to save time writing to a text file, set a document the way you want to code it in your script (add objects,classes,etc.) and use Export->Vectorscript to save the resulting code to a text file. Look for the object creation section and then copy relevant code into your script. I draw what I want. I make it into a Symbol Named 'ThisPart' I export the script to a text file. I open it and search for 'ThisPart'. I cut and paste the section of script from BeginSym; to EndSym;. Delete the Sym from Begin[sym] and End[sym]. Add a Procedure (name). Marvelous. Quote Link to comment
Assembly Posted December 18, 2009 Author Share Posted December 18, 2009 Thanks for both Links Pat- Have you used Dialog Creator?. Quote Link to comment
Pat Stanford Posted December 18, 2009 Share Posted December 18, 2009 I have tried it, but Didn't really need the power it has, so I just touched the surface. Seem capable. Quote Link to comment
Kool Aid Posted December 18, 2009 Share Posted December 18, 2009 I'm thinking the WriteLn function might be a very powerful tool... with it you can write a script to write a script. In the TellMeVariable I included a function that picks up all the parameter names then creates assigns the internal variables to the object parameters. I am just starting to play around with Dialogs- is anyone using WriteLn in scripts to auto generate Dialog Scripts?. If this question make sense and there a couple people interested in seeing how it might be done, I've been looking for a project to give Google Wave a go on- and I have a couple spare invites. See also http://www.nemetschek.net/support/custom/vscript/vstool.php Dialog Builder 5 and everything at http://www.vectorlab.info/index.php?title=Category:Examples_-_Dialogs Scripts that generate scripts are a favourite of mine. I also have FileMaker Pro databases that generate scripts. However, as comes to dialogs, I'll leave that to the experts and aficionados. (We hatess dialogss?) Quote Link to comment
Assembly Posted December 18, 2009 Author Share Posted December 18, 2009 Dialog Builder 5. Downloaded, installed - looks very good indeed, thanks. Quote Link to comment
Assembly Posted December 18, 2009 Author Share Posted December 18, 2009 umm... this maybe obvious... how do you change the size of a Dialog Window?. Does not seem to be part of the CreateLayout procedure. Quote Link to comment
Vectorworks, Inc Employee klinzey Posted December 18, 2009 Vectorworks, Inc Employee Share Posted December 18, 2009 Dialogs are dynamicaly sized based on the controls. If you create a resizable dialog there are VS calls to set/get the size and location of the dialog. (SetLayoutDialogSize() for the size) If you are talking about using the Dialog Builder there is a control point in the lower right corner to resize the layout window. Quote Link to comment
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.