gScott Posted May 10, 2007 Share Posted May 10, 2007 i'm trying to convert an old microstation script to draw site diagrams, but cant' find a function in vectorscript to draw a line by distance + angle. in microstation the script is: place smartline xy=0,0 DI=, DI=, DI=, DI=, etc... xy=0,0 in vectorscript i can only find LineTo(X,Y); is there a vector equivalent? any help would be much apreciated... regards gideon scott Quote Link to comment
MullinRJ Posted May 10, 2007 Share Posted May 10, 2007 (edited) Hi Gideon, You have to convert your distance and angle to X & Y displacement, but it can be done with a few lines of code. MoveTo(X, Y); { Draw first point } A := Deg2Rad(A); dX := L * cos(A); dY := L * sin(A); LineTo(X+dX, Y+dY); { Draw last point } where L = Length, and A = Angle in degrees. You can also do it with vector math, but it's pretty much the same approach. Raymond Edited May 11, 2007 by MullinRJ Quote Link to comment
gScott Posted May 11, 2007 Author Share Posted May 11, 2007 thanks raymond, i was hoping to avoid all the extra typing though! Quote Link to comment
MullinRJ Posted May 11, 2007 Share Posted May 11, 2007 But the beauty of scripting is you only have to type it once. If you want to be able to use the code in your script to draw several lines, define a procedure with the code and call it once per line you want to draw. procedure LinePolar(X, Y, L, A :Real); { Draw a Line from point (X, Y) to another point specified by length L and angle A (in degrees). } Begin A := Deg2Rad(A); { change A to radians } MoveTo(X, Y); { Move to first point } LineTo(X+L*cos(A), Y+L*sin(A)); { Draw to second point } End; { LinePolar } Instesd of MoveTo(); and LineTo(); calls to draw a line, use: LinePolar(1, 2, 5, 53.1301); which is the same as: MoveTo(1, 2); LineTo(4, 6); The same could be done for LineToPolar(), which you may want to use if you are chaining segments together. Let me know, or try your hand at it. It's not hard. Though, if that's the case, you probably should be using Polygons. HTH, Raymond Quote Link to comment
gScott Posted May 11, 2007 Author Share Posted May 11, 2007 raymond thanks for the help, in the end i've got my external spreadsheet, where i enter the site data, to do all the geometry calculations + generate an 'include' text file. the weird thing now is that the import script that pulls the file in works the 1st time i use it, but if i edit the external worksheet, regenerate the 'include' file, and run the import again it draws the original site shape, not the updated shape. i've checked that the 'include' file is correctly updating, but it seems that the original data is lurking in some cache. if i recompile the import script the updated shape is drawn correctly the 1st time the script is re-run, but thereafter it doesn't update again. is there a way to 'flush' the include file from memory? Quote Link to comment
islandmon Posted May 11, 2007 Share Posted May 11, 2007 i've checked that the 'include' file is correctly updating, but it seems that the original data is lurking in some cache The original data is linked via ObjectID# > #include container which then imports the FilePath data. Recompiling the script requires the #Include container to import the #Include data from the designated FilePath. Perhaps, a FilePath dialog would work to reset the contents of the #include container Quote Link to comment
ccroft Posted May 12, 2007 Share Posted May 12, 2007 (edited) This is 'compiler mode'. If you have an industry series product there's a menu command somewhere under scripts to turn script caching on and off. If you're using fundamentals add SetPref(407, True) to stop caching plug-in scripts. You might want to make a pref toggle script to turn caching on and off as needed. Edited May 12, 2007 by ccroft Quote Link to comment
gScott Posted May 13, 2007 Author Share Posted May 13, 2007 ccroft, what kind of performance affect is that going to have on all other PIO's if left ON? Quote Link to comment
MullinRJ Posted May 14, 2007 Share Posted May 14, 2007 Hi Gideon, Leaving that preference ON will noticeably slow down all PIO scripts, especially the big ones. When developing PIO scripts I leave it on all the time, and toggle it off when I want to see how a script will perform in reality. Under normal operating scenarios I leave it OFF. Raymond Quote Link to comment
Miguel Barrera Posted May 24, 2007 Share Posted May 24, 2007 Hi Gideon, Input by distance-angle is built into vectorscript already. No need for special funtion to convert to polar coordinates. Search for "Distance-angle Mode" in the VW help for input details. Quote Link to comment
gScott Posted May 24, 2007 Author Share Posted May 24, 2007 raymond i forgot that i had set it ON, then couldn't figure out why VW was running at 90% cpu load all the time... and re-installed from scratch not the brightest spark... Quote Link to comment
gScott Posted May 24, 2007 Author Share Posted May 24, 2007 miguel thanks for that, i previously searched HELP for 'vectors' and got nowhere... amazing how you can't find stuff if you can't find the right words to ask the question with? Quote Link to comment
gScott Posted May 27, 2007 Author Share Posted May 27, 2007 Perhaps, a FilePath dialog would work to reset the contents of the #include container islandmon, can you give me a clue how to do this? i've got my diagrams working well using the distance-angle mode, but still have to manually run a 'SetPref(407, True)' script in advance. adding this into the diagram script doesn't work. any advice would be appreciated. Quote Link to comment
islandmon Posted May 27, 2007 Share Posted May 27, 2007 {$Include filename } { implied to be in the Plug-Ins folder } {$Include \Drive Name\folder\file name } { anywhere on your system } MullinRJ check-out: http://techboard.nemetschek.net/ubbthreads/ubbthreads.php?ubb=showflat&Board=13&Number=55386&Searchpage=1&Main=12974&Words=include&topic=0&Search=true#Post55386 Quote Link to comment
ccroft Posted May 28, 2007 Share Posted May 28, 2007 Gideon If you can restructure things in a way that allows you to use standard File I/O type calls like ReadLn instead of Include, I don't think you'll have the caching prob. I have Menu Commands that use GetFile, and the data is read anew each time. GetFile uses a dialog to select the file though, and this isn't something you usually want in a VSO since it will be displayed anytime Objects are regenerated. I'm not 100% sure what will happen if you use Open(filename), but you'd think it would be the same. It sounds like you are exporting a delimited text file from Excel that has all the distance/angle info and your PIO does the rest. File i/o is designed for this kind of work, and is used in some of the standard PIO's to read files in the Data folder in PlugIns folder. I'm not sure how you are using Include for this. I've only used it for importing code. Charles Quote Link to comment
gScott Posted May 28, 2007 Author Share Posted May 28, 2007 charles thanks for that, but your tips are a bit beyond me, + i can't figure how to get my file in that way. my spreadsheet converts local site data, which comes in a variety of units + as either XYZ or distance/angle format, into metric + then outputs a text file to draw the site poly eg. BeginPoly; MoveTo(0,0); LineTo(10m,#45d0'0"); LineTo(10m,#-45d0'0"); LineTo(10m,#-135d0'0"); LineTo(11m,#-225d0'0"); ClosePoly; EndPoly; i've tried modifying my spreadsheet output to be able to use the 'import survey file' function, which works fine, but doesn't draw the site poly... Quote Link to comment
ccroft Posted May 29, 2007 Share Posted May 29, 2007 Gideon Please post a few lines of your text file, the file you are $including. Quote Link to comment
gScott Posted May 29, 2007 Author Share Posted May 29, 2007 charles the $include file varies by the complexity of the site, but is basically as follows: TextFont(GetFontID('Arial')); TextSize(12); BeginPoly; MoveTo(0,0); BeginText; 'a' EndText; LineTo(10m,#45d0'0"); BeginText; 'b' EndText; LineTo(10m,#-45d0'0"); BeginText; 'c' EndText; LineTo(10m,#-135d0'0"); BeginText; 'd' EndText; LineTo(11m,#-225d0'0"); ClosePoly; EndPoly; Quote Link to comment
ccroft Posted May 30, 2007 Share Posted May 30, 2007 Maybe I totally mis-understand what's going on here. You mean to say that you're writing all this in Excel? I'm wondering what the raw Excel data looks like. Typically the way this works is to export only the numbers needed for drawing from Excel as a delimited text file...it's just a structured list of values. The vScript contains the drawing code. It only reads the values from the text file. The code is in the plugin, and the data is in the text file. If you would like to email me an Excel file, maybe I can help you further. Sending the PIO wouldn't hurt either. chacroATshaw.ca (old habit...don't know if spambots get in here or not) Charles 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.