vhector Posted February 18, 2009 Share Posted February 18, 2009 I got no experience with scripting, so tried a pop-up samplescript (scalebar) in a more simplistic form. But got errors like identifier and labels. I read that identifier had to do with the compiler. Can somebody explain maybe these terms bettter, so I'll could go further on stying scripting. Here is the basic script I'm working at. Procedure Tree; VAR treestyle :INTEGER barval :STRING; BEGIN {VectorWorks Version 14.0.2(99197)} { set tree style } IF barval = 'TreeA' THEN treestyle:= 1 ELSE IF barval = 'TreeB' THEN treestyle:= 2 ELSE IF barval = 'TreeC' THEN treestyle:= 3; { TreeA-style tree } 1:BEGIN { draw tree } PushAttrs; {Object Creation Code} PenSize(2); PenPat(2); FillPat(1); PenFore(0,0,0); PenBack(65535,65535,65535); FillFore(0,0,0); FillBack(25307,46041,23648); Oval(-50.875,50.875,50.875,-50.875); SetZVals(0,0); {End of Creation Code} PopAttrs; END; { TreeB-style tree } 2:BEGIN { draw tree } PushAttrs; {Object Creation Code} PenSize(2); PenPat(2); FillPat(1); PenFore(0,0,0); PenBack(65535,65535,65535); FillFore(0,0,0); FillBack(25307,46041,13648); Oval(-50.875,50.875,50.875,-50.875); SetZVals(0,0); {End of Creation Code} PopAttrs; END; { TreeC-style tree } 3:BEGIN { draw tree } PushAttrs; {Object Creation Code} PenSize(2); PenPat(2); FillPat(1); PenFore(0,0,0); PenBack(65535,65535,65535); FillFore(0,0,0); FillBack(12307,46041,23648); Oval(-50.875,50.875,50.875,-50.875); SetZVals(0,0); {End of Creation Code} PopAttrs; END; END; Run(Tree); Quote Link to comment
Pat Stanford Posted February 18, 2009 Share Posted February 18, 2009 You where pretty close. You where missing a semicolon at the end of theInteger variable definition, you did not have a way to let the user enter the tree type, and you needed a way to select which type of tree to draw. I used a CASE statement around your three drawing routines. Procedure Tree; VAR treestyle :INTEGER; barval :STRING; BEGIN {mail procedure} {VectorWorks Version 14.0.2(99197)} barval:=StrDialog('Enter Type of Tree','TreeA'); {this will let the user type in the tree type} { set tree style } IF barval = 'TreeA' THEN treestyle:= 1 ELSE IF barval = 'TreeB' THEN treestyle:= 2 ELSE IF barval = 'TreeC' THEN treestyle:= 3; Case treestyle of {Case statement select one set of code from a list of options} { TreeA-style tree } 1:BEGIN {treeA} { draw tree } PushAttrs; {Object Creation Code} PenSize(2); PenPat(2); FillPat(1); PenFore(0,0,0); PenBack(65535,65535,65535); FillFore(0,0,0); FillBack(25307,46041,23648); Oval(-50.875,50.875,50.875,-50.875); SetZVals(0,0); {End of Creation Code} PopAttrs; END; {treeA} { TreeB-style tree } 2:BEGIN {treeB} { draw tree } PushAttrs; {Object Creation Code} PenSize(2); PenPat(2); FillPat(1); PenFore(0,0,0); PenBack(65535,65535,65535); FillFore(0,0,0); FillBack(25307,46041,13648); Oval(-50.875,50.875,50.875,-50.875); SetZVals(0,0); {End of Creation Code} PopAttrs; END; {treeB} { TreeC-style tree } 3:BEGIN {treeC} { draw tree } PushAttrs; {Object Creation Code} PenSize(2); PenPat(2); FillPat(1); PenFore(0,0,0); PenBack(65535,65535,65535); FillFore(0,0,0); FillBack(12307,46041,23648); Oval(-50.875,50.875,50.875,-50.875); SetZVals(0,0); {End of Creation Code} PopAttrs; END; {treeC} End; {case} END; {main procedure} Run(Tree); Quote Link to comment
vhector Posted February 19, 2009 Author Share Posted February 19, 2009 Many thanks Pat I now get the object and can change it in the 'enter text' dialog but not with the pop-up parameter. How do I do that. I made in the parameters a new pop-up, and wrote in the choices the TreeA/B/C names. What do I put in the script for connecting it. Has it to do with this line " barval:=StrDialog('Enter Type of Tree','TreeA'); {this will let the user type in the tree type}". Instead of 'Enter Type of Tree','TreeA', something with parameter. Quote Link to comment
vhector Posted February 20, 2009 Author Share Posted February 20, 2009 (edited) I read in the VSLG that it has to do with 'resultStatus:=GetCustomObjectInfo(objName); {brings it to the object info palette I guess} I resultStatus THEN BEGIN I tried to use but again errrors Procedure Tree; VAR treestyle :INTEGER; barval,objName :STRING; BEGIN {mail procedure} {VectorWorks Version 14.0.2(99197)} { retrieve custom object information } resultStatus:= GetCustomObjectInfo(objname); { if custom object data was retrieved successfully } IF resultStatus THEN BEGIN { retrieve parameter values } barval := PTREE_STYLE; { set tree style } IF barval = 'TreeA' THEN treestyle:= 1 ELSE IF barval = 'TreeB' THEN treestyle:= 2 ELSE IF barval = 'TreeC' THEN treestyle:= 3; Case treestyle of {Case statement select one set of code from a list of options} { TreeA-style tree } 1:BEGIN {treeA} { draw tree } PushAttrs; {Object Creation Code} PenSize(2); PenPat(2); FillPat(1); PenFore(0,0,0); PenBack(65535,65535,65535); FillFore(0,0,0); FillBack(25307,46041,23648); Oval(-50.875,50.875,50.875,-50.875); SetZVals(0,0); {End of Creation Code} PopAttrs; END; {treeA} { TreeB-style tree } 2:BEGIN {treeB} { draw tree } PushAttrs; {Object Creation Code} PenSize(2); PenPat(2); FillPat(1); PenFore(0,0,0); PenBack(65535,65535,65535); FillFore(0,0,0); FillBack(25307,46041,13648); Oval(-50.875,50.875,50.875,-50.875); SetZVals(0,0); {End of Creation Code} PopAttrs; END; {treeB} { TreeC-style tree } 3:BEGIN {treeC} { draw tree } PushAttrs; {Object Creation Code} PenSize(2); PenPat(2); FillPat(1); PenFore(0,0,0); PenBack(65535,65535,65535); FillFore(0,0,0); FillBack(12307,46041,23648); Oval(-50.875,50.875,50.875,-50.875); SetZVals(0,0); {End of Creation Code} PopAttrs; END; {treeC} End; {case} END; {main procedure} Run(Tree); Edited February 20, 2009 by vhector Quote Link to comment
Pat Stanford Posted February 21, 2009 Share Posted February 21, 2009 When you create your popup, give it a simple name with no spaces. We are going to use that as a variable in the script. I am going to call it TreeType. You can give the Alternate Name a longer more descriptive name as that is what will show up in the Object Info Palette. To use anything you have defined as a parameter, you just use the name and preface it with a lower case p. So mine would be called pTreeType. You should be able to change the StrDialog line to: barval:=pTreeType; and have it work. Or actaully you could delete the StrDialog line entirely and just replace barval with pTreeType throughout the script. Let me know if you need more help. Quote Link to comment
vhector Posted February 23, 2009 Author Share Posted February 23, 2009 Many thanks Pat, Good change you hear from me again in trying to understand the scripting. 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.