Jump to content
Developer Wiki and Function Reference Links ×

Tell Me Variables


Assembly

Recommended Posts

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.

Link to comment

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

Link to comment
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.

Link to comment

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?)

Link to comment
  • Vectorworks, Inc Employee

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.

Link to comment

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