michaelk Posted August 6, 2013 Share Posted August 6, 2013 Can anyone point me to an explanation of GetViewMatrix and SetViewMatrix? Thanks MK Quote Link to comment
michaelk Posted August 6, 2013 Author Share Posted August 6, 2013 Why does it return a Boolean and not 4 real numbers? mk Quote Link to comment
James Russell Posted August 7, 2013 Share Posted August 7, 2013 Michael, Present! (See attached!) I've never touched these two functions until about 30mins ago but I think I've got them. I had to go back to some 2007 documentation though to find out that it's 6 vars not 4 as the current documentation says. Here's a little script I whipped up (Sorry it's messy, wrote it at lunch...): -------------------------- Procedure VPTest; VAR h,WSH:Handle; x, y, cx, cy, cz, rotx, roty, rotz : REAL; str1,str2,str3,str4,str5,str6 :String; xxx:Boolean; Begin GetPt(x, y); h:=PickObject(x, y); xxx:=GetViewMatrix(h,cx,cy,cz,rotx,roty,rotz); WSH:=CreateWS('Values',10,10); Str1:=Num2Str(3,cx); Str2:=Num2Str(3,cy); Str3:=Num2Str(3,cz); Str4:=Num2Str(3,rotx); Str5:=Num2Str(3,roty); Str6:=Num2Str(3,rotz); SetWSCellFormula(WSH,1,1,1,1,'X-Coord'); SetWSCellFormula(WSH,1,2,1,2,'Y-Coord'); SetWSCellFormula(WSH,1,3,1,3,'Z-Coord'); SetWSCellFormula(WSH,1,4,1,4,'X-Rot'); SetWSCellFormula(WSH,1,5,1,5,'Y-Rot'); SetWSCellFormula(WSH,1,6,1,6,'Z-Rot'); SetWSCellFormula(WSH,2,1,2,1,Str1); SetWSCellFormula(WSH,2,2,2,2,Str2); SetWSCellFormula(WSH,2,3,2,3,Str3); SetWSCellFormula(WSH,2,4,2,4,Str4); SetWSCellFormula(WSH,2,5,2,5,Str5); SetWSCellFormula(WSH,2,6,2,6,Str6); ShowWS(WSH,true); End; Run(VPTest); ---------------------- Should work on any viewport placed and then you just have to click on it and the script will generate a worksheet for the data. Attached is my quick testing file. Although I haven't touched SetViewMatrix I'd imagine it's pretty easy after this. Let me know how you go, I'm interested to know what you're using this for! J Quote Link to comment
michaelk Posted August 7, 2013 Author Share Posted August 7, 2013 James Interesting. You don't actually do anything with the boolean value. You just say the boolean variable is equal to GetViewMatrix to get the values.... I think I see how it works. I don't understand why it works that way... If it works I'll send it to you! mk Quote Link to comment
Vectorworks, Inc Employee Matt Panzer Posted August 7, 2013 Vectorworks, Inc Employee Share Posted August 7, 2013 Hi Michael, The boolean will be true if the function was successful, false if not. These boolean functions can be written like this: GotIt := GetViewMatrix(h,cx,cy,cz,rotx,roty,rotz); IF GotIt THEN do my stuff ELSE do something else; Often times, there's not a need to do this and it can be used with a dummy var as James shows. I usually have a boolean variable called "boo" in scripts to use this way. Quote Link to comment
michaelk Posted August 7, 2013 Author Share Posted August 7, 2013 Hi Matt I see that it works this way. But why does it behave so differently from other Get functions? For example, I've been playing around with GetBBox. It works like all other Gets GetBBox(h,p1X,p1Y,p2X,p2Y); returns the real values for the 2 points of object with handle h. It's not boo := GetBBox(h,p1X,p1Y,p2X,p2Y); Am I missing something that's fundamentally different about GetViewMatrix from all the other Get functions (that I know about)? Or is it just that way because it's that way? mk Quote Link to comment
Vectorworks, Inc Employee klinzey Posted August 7, 2013 Vectorworks, Inc Employee Share Posted August 7, 2013 Having a functions return a Boolean is rather standard for new calls. If the return value is FALSE the function failed for some reason. (Unsupported object type, invalid handle etc.) Without a Boolean return you had to guess that the function failed by looking at the return values. This is an extreme example and why you need to do type checking but you have no way of knowing that GetBBox gives you invalid information if you pass it the handle to a record format object. If you pass GetViewMatrix the same handle it will return FALSE. Quote Link to comment
Vectorworks, Inc Employee Matt Panzer Posted August 7, 2013 Vectorworks, Inc Employee Share Posted August 7, 2013 There are quite a few more that work that way. It would be nice if things were more consistent (in how the functions are named) so it was more obvious which of the "Gets" worked this way. Some "Gets" are procedures, some are functions that return the desired value, and some are these boolean functions that report back a success/fail. Knowing the success/fail of the function does come in quite handy sometimes. Quote Link to comment
michaelk Posted August 7, 2013 Author Share Posted August 7, 2013 Thank you, gentlemen. mk Quote Link to comment
Pat Stanford Posted August 7, 2013 Share Posted August 7, 2013 GetBBox(h,p1X,p1Y,p2X,p2Y); returns the real values for the 2 points of object with handle h. It's not boo := GetBBox(h,p1X,p1Y,p2X,p2Y); Am I missing something that's fundamentally different about GetViewMatrix from all the other Get functions (that I know about)? The main thing you are missing is the age of the function. GetBBox has been around forever (I think literally. I believe it was in the first version of MiniPascal). GetViewMatrix is much newer, coming some time since it was converted to Vectorscript. Newer in this case means that NV has learned what makes the functions/procedures easier/better for them to use internally and that flows down to all of us. Luckily, they also understand that changing the definitions of procedures that are used in scripts who know how old will break many things and cause howls of outrage sot they have not done that (much) yet. Quote Link to comment
michaelk Posted August 7, 2013 Author Share Posted August 7, 2013 The main thing you are missing is the age of the function. Glad to know that it's just progress and not another concept I don't understand! mk 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.