orlando Teixeira Posted April 13, 2009 Share Posted April 13, 2009 hello again, The scripts runs smooth but i want i am new to vectorscript and probably this is all messed up and thats why i would like some help. Can someone help me improving this ? PROCEDURE FindYcoord; VAR x1, y1 : REAL; x2, y2 : REAL; textArray : DYNARRAY[] OF CHAR; h,hg:handle; CurrentCl:string; BEGIN DSelectAll; CurrentCl:=ActiveClass; NameClass('cota altimetrica'); SetClUseGraphic(' cota altimetrica',true); SetClPenFore(' cota altimetrica',0,0,0); SetClPenBack(' cota altimetrica',0,0,0); SetClLW(' cota altimetrica',1); SetClLS(' cota altimetrica',5); SetClFPat(' cota altimetrica',0); ShowClass(' cota altimetrica'); LSByClass; LWByClass; PenColorByClass; FillColorByClass; FPatByClass; NameClass(CurrentCl); GetPt(x1,y1); MoveTo(x1,y1); x2 := x1 - 0.10; Y2 := y1 + 0.17; LineTo(x2,y2); MoveTo(x1,y1); x2 := x1 + 0.14; Y2 := y1 + 0.25; LineTo(x2,y2); x2 := x2 + 0.6; LineTo(x2,y2); TextSize(6); TextJust(2); TextVerticalAlign(4); x2 := x2 - 0.3; y2 := y2 + 0.02; TextOrigin (x2,y2); FillPat(0); BeginText; Concat('',Num2StrF (y1) ,'' ) EndText; Group; DSelectAll END; RUN(FindYcoord); Quote Link to comment
Pat Stanford Posted April 13, 2009 Share Posted April 13, 2009 (edited) If ti runs and does what you want, then it is a good script. Several comments: 1. You might want to check and see if the altimetrica class exists and if it does then just activate it rather than redfining it every time you run the script. Check out the ClassList and ClassNum and then step through the class list to see if it is already there. If you have a lot of classes, then what you have might be faster, but it eliminates the ability to redefine the class attributes unless you edit the script. 2. With your NameClass(CurClass) function where it is, all of the objects you draw in the routine will be in the current class, not altimetrica. Move it to the bottom of the script. 3. If there might be cases where you don't want to change the selection state, you can use the BeginGroup and EndGroup statements around your object create code rather then the Group statement at the end. If you do this, then you can also eliminate the DSelectAll from the top of the script. Looks like a good start. ps. we discourage cross posting to multiple forums. Since this is the better place for this. I answered it here. Please post to only one location, with possibly a redirection from the other thread in the future. Edited April 13, 2009 by Pat Stanford Quote Link to comment
orlando Teixeira Posted April 14, 2009 Author Share Posted April 14, 2009 Hello Pat, sorry for the "multiple posts" but i wanted to get an solution real quick because i had a project to finish and as no one helped me i thought everyone had gone home.... in all cases i achieved to make that simple (but complicated to me) script just yesterday after finishing the project and i had to use the "elevation benchmark" in the project that gave me far more work than this little script will do for me in the next ones. remarks : 1. ok i thought of that but as i cant find some good tutorial about vectorscript i am searching in vectordepot for scripts that are similar to the things i want and then ajust. I didnt find yet the way to do that. i know that i have to make an if statment ... thats a start point he!he!he! 2. thx for this tip ... i was wondering why the heck this didnt worked as i wanted... 3. i didnt tryit yet, but i will, that begin and end group looks very nice and usefull. i use Dselectall at the begining because my very first script (this one is my second) if i had some objects selected they all ended as guides .... A) By the way (speaking in my very first script) how can i constrain to vertical or horizontal the creation of a line ? my problem is that the script does not constrain like vectorworks normaly do, it just not constrain at all but my constrains are turn on... thx very much Quote Link to comment
Pat Stanford Posted April 14, 2009 Share Posted April 14, 2009 Except for Jonathan Pickups manual and Robert Anderson's post in the Resource Share:Vectorscript forum called the Vectorscript Advisor, there are not a lot of other resources. Probably the best is the vectorscript wiki at VCOR. http://www.vectorlab.info/index.php?title=Category:VectorScript It has lots of user generated information. Have you read the Vectorscript Language Guide in the VW help? It is really the definitive reference on how to use statments and commands in VW. Quote Link to comment
orlando Teixeira Posted April 14, 2009 Author Share Posted April 14, 2009 Hello Again, anyway , how do i constrain line creation direction ? Do you mean "VectorScript Function Reference" ? because other stuff that i found in vectorworks help was about running and creating scripts in vectorworks, not a guide to the programming language itself.... but yes you are right. VCOR: I didnt ever seen it yet, one of those things..... Jonathan Pickups manuals : everybody says they are very good but....payed manuals .... Robert Anderson's posts : ok as i dont come here that ofen i never camed across it yet but i will stay alert. thx Pat Quote Link to comment
Pat Stanford Posted April 14, 2009 Share Posted April 14, 2009 Go to the Help menu and then to Vectorworks Help. in the top left frame one of the options is Vectorscript Language Guide. I would say there are two ways to learn Vectorscript. 1. Buy Jonathan's book and get a head start. 2. Spend lots (and lots) of time cruising the forum and the web trying to find some obscure bit of information you need. Actually, even if you do buy Jonathan's book you will still need to do number 2, but it will take less time. How much do you value your time versus your money? Quote Link to comment
orlando Teixeira Posted April 15, 2009 Author Share Posted April 15, 2009 Hello again PAT As i usually do what i do every day, and allways are in a hurry to finish projects i checked vectorworks help very very fast .... why the heck didnt i crossed with vectorscript help ? this will be very helpfull, thx "Actually, even if you do buy Jonathan's book you will still need to do number 2, but it will take less time." Ok you have explained why i couldnt find easy any information about vectorscript ...thats a shame because every day i like vectorworks more and more and customization is allways a part of evolution. Thx PAT once again for your pacience with me. I definitly will return here. whenever i can ps. still searching for how to constrain (in this case ) direction line angle in vectorscript cya Quote Link to comment
Pat Stanford Posted April 15, 2009 Share Posted April 15, 2009 I don't understand what you mean by constrain the line. In VW, you just give the commands to draw a line a certain length at a certain angle (or from a point to a point). What is there to constrain? Quote Link to comment
Dieter @ DWorks Posted April 16, 2009 Share Posted April 16, 2009 I don't understand what you mean by constrain the line. In VW, you just give the commands to draw a line a certain length at a certain angle (or from a point to a point). What is there to constrain? I think I know what he means: When the use clicks two points, even if the points are not horizontal for example, the line still must be horizontal from the first point to the x of the second point. I done this in one of my scripts and it's fairly easy to implement. Just take the first point to draw the line, and take the x from the second point and the y from the first point as to where the line must go. If the line must be vertical, just switch x and y. Quote Link to comment
orlando Teixeira Posted April 16, 2009 Author Share Posted April 16, 2009 Hello Again, DWorks , yes you are right but that way i must create 2 scripts and i wanted to create just one. So after some research i achieve to make it trought Hangle. My problem here is that it only draws horizontal line. How can i change this to draw vertical also ? PROCEDURE DrawXline; VAR x1, x2, y1, y2, ang : REAL; BEGIN DSelectAll; GetPt(x1,y1); GetPtL(x1,y1,x2,y2); ang:=HAngle(LNewObj); if (ang < 90) OR (ang > 270) THEN y2:=y1 else if (ang > 90) OR (ang < 270) THEN x2:=x1; MoveTo(x1,y1); LineTo(x2,y2); Scale(1000,1000); DSelectAll; END; RUN(DrawXline); Quote Link to comment
Pat Stanford Posted April 16, 2009 Share Posted April 16, 2009 GetPtLine does not create an object, so the Hangle you are getting is from some other object. Also, the GetLine will give you a better interface than GetPt/GetPtLine. Try this instead: PROCEDURE DrawXline; VAR x1, x2, y1, y2 : REAL; BEGIN GetLine(x1,y1,x2,y2); if abs(X2-X1) > abs(Y2-Y1) THEN y2:=y1 else x2:=x1; MoveTo(x1,y1); LineTo(x2,y2); Scale(1000,1000); DSelectAll; END; RUN(DrawXline); Quote Link to comment
orlando Teixeira Posted April 20, 2009 Author Share Posted April 20, 2009 Hello Again Thx Pat that worked like a charm. even if we remove the "if statment" it works perfectly . Just one thing : If i have other objects select when i call this little script it just scales everything selected .this is the reason why i allways use DSelectAll; at the begining of this script. Thx again Pat and DWorks You have been Great. Quote Link to comment
Pat Stanford Posted April 20, 2009 Share Posted April 20, 2009 Try replacing the Scale line with: HCenter(LNewObj,X3,Y3); HScale2D(LNewObj,X3,Y3,1000,1000); This will only scale the object you just created and not have to change your selection state. This comes from the on-line VS reference. It shows some functions not listed in the regular VS documentation. http://developer.vectorworks.net/index.php?title=VS:HScale2D Quote Link to comment
orlando Teixeira Posted April 28, 2009 Author Share Posted April 28, 2009 Hello again Pat. & DWorks How are you both? Sorry for my late response. Thx again for your answer PAT, its Very usefull. thx 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.