MaxStudio Posted January 25, 2013 Share Posted January 25, 2013 I have a Plug In Object. When I select the Plug In Object I would like to see calculations (such as Area) displayed in the Object Info Palette. Much like how it displays "Area" & "Perimeter" when a person creates a rectangle. Does anyone know how to make this happen? I already have variables and the calculations. I just need to know how to have it displayed in the OIP. I will further investigate. Thank You. Quote Link to comment
JBenghiat Posted January 25, 2013 Share Posted January 25, 2013 Create a parameter of type Static Text. Use SetRField to assign a value to the parameter. Use GetCustomObjectInfo to get the handle to the plug-in, and the plug-in name. Pass the plug-in name as the record name. Don't include the "P" in the field name. Use Num2StrF to convert any distances to strings. HTH, Josh Quote Link to comment
Hippocode Posted January 28, 2013 Share Posted January 28, 2013 And when its a 2d poly it displays the area and perimeter without having to do anything Quote Link to comment
MaxStudio Posted January 28, 2013 Author Share Posted January 28, 2013 Ok this is what I have and it works. The only problem is it is displaying the results in the OIP in inches... is there a way to get it to display as feet and inches... ex: the rectangle is 3'-0" wide x 2'-0 high, the width is displaying as 36.00 and the area displays as 864.00 I would like to have it display as width 3'-0" and area as 6 sq ft. do i have to do the math and break it down using a concat? Thanks PROCEDURE plugin; VAR x, y, w, h, area : REAL; widthdisplay, areadisplay: STRING; result : BOOLEAN; objname : STRING; oh,rh,wh : HANDLE; BEGIN { retrieve custom object information } result:= GetCustomObjectInfo(objname,oh,rh,wh); { if object information was successfully retrieved } IF result THEN BEGIN { retrieve parameters } w := PW; h := PH; rect(x,y,x+w,y+h); area:=w*h; widthdisplay:=Num2Str(2,w); areadisplay:=Num2Str(2,area); SetRField(oh,objname,'Width',widthdisplay); SetRField(oh,objname,'Area',areadisplay); END; END; Run(plugin); Quote Link to comment
JBenghiat Posted January 28, 2013 Share Posted January 28, 2013 Num2StrF will return a string using the current units setting. -Josh Quote Link to comment
Miguel Barrera Posted January 28, 2013 Share Posted January 28, 2013 If the current unit format is feet & inches, you can use the Num2StrF to display the document format. However, for any other format, such as inches or feet, you would need to convert (inches in your case) to the desired format (sq. ft.) Whatever the document units are, you can get the "units per inch" to convert to feet. Quote Link to comment
MaxStudio Posted January 28, 2013 Author Share Posted January 28, 2013 (edited) Thanks guys I was able to get it to work. Now I'm trying to get more than one calculation to display but it is not allowing me do it. currently I have the following: widthstring:=Num2StrF(w); SetRField(oh,objname,'Width',widthstring); heightstring:=Num2StrF(h); SetRField(oh,objname,'Height',heightstring); Both static parameters show up in the OIP, but only one (the first one) displays the calculation. Any idea why? Do I need to have a separate handle and or object name for each? Edited January 28, 2013 by MaxStudio Quote Link to comment
JBenghiat Posted January 28, 2013 Share Posted January 28, 2013 I don't see any inherent problems in the code. Check to see that your parameter is called "Height," without any spelling errors. FYI, you can nest procedures, compacting the code to: SetRField(oh,objname,'Width',Num2StrF(w)); The only downside to doing so is debugging can be a bit harder. -Josh Quote Link to comment
MaxStudio Posted January 28, 2013 Author Share Posted January 28, 2013 i got it working. I believe it was something as simple as not hitting return after my final line of code. Thanks for your help. Quote Link to comment
David Bengali Posted July 7, 2017 Share Posted July 7, 2017 (edited) I am running into an issue related to this topic, wondering if it has come up for anyone else: On the VW install on which I have been developing a plugin, I have had no problems when units are set to Feet and Inches, but when moving the plugin to other computers, suddenly I get an error trying to set the value of Static Text parameters when the units are in Feet and Inches. It looks like somewhere within vectorworks, beyond the level of my plugin's code, there is a problem escaping quote marks. I am building in Python. Here is an example of some code: diag = (width * width + height * height) ** (0.5) vs.SetRField(oh, objname, 'Diag', vs.Num2StrF(diag)) the variables width and height are all the result of calculations based on dimension parameter fields. On the computer where things function correctly, the math works out accurately, and the static text parameter called "Diag" is updated with a value that looks correct, and includes feet and inches quote marks however, on some other computers, I get this error: File "<string>", line 1444 vs.PDiag = '14'1.706"' ^ Syntax Error: invalid syntax There is no direct assignment to the "Diag" parameter in the code, as this error would suggest. Only the SetRField call shown above. This would suggest that somewhere behind the scenes, vectorworks is trying this assignment, and failing because of unescaped quote marks. I do not get this error in other unit modes. And it is strange that I do not get this error on every computer. Any ideas from the group? Edited July 7, 2017 by David Bengali Quote Link to comment
David Bengali Posted July 7, 2017 Share Posted July 7, 2017 I think I have solved this - It seems VW was not updated to the latest service pack for 2017 on the problem computers, and upon updating, the behavior appears fixed. I should have checked that first. I imagine this is a known bug that is documented in the release notes somewhere. 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.