tsw Posted July 11, 2019 Share Posted July 11, 2019 Hello, Is there a function to return a wall style component name using its "Function" attribute in a worksheet? I'd like to make a schedule similar to the image below. I can get close using a database header of =COMPONENTNAME(1), =COMPONENTNAME(2), etc... but it falls apart if I don't have exactly 3 components in a wall type. Thanks for suggestions! Quote Link to comment
Pat Stanford Posted July 12, 2019 Share Posted July 12, 2019 The following worksheet script will return the component index of the first component in a wall that has the Function specified by the passed integer. Put this in a database and it will give you the Load-Bearing component of each wall. Use that returned value in a =ComponentName() function to get the name. You may want to put the Index into a column that can be hidden. This script can be run in any file that it exists in. If you want to get fancy, you can slightly change the way the script is called and store it as a text file accessible from any VW file. Copy and paste everything in the code block below into a new black script file (from the Resource Browser). Make sure the script is named ComponentIndex. Use the function =RunScript('ComponentIndex',1) to get the Load-Bearing component index. If you put this in database cell C3, then set C4 to =ComponentName(C3) to get the name of the component. Ask again if you have more questions. Procedure ComponentIndex; {July 11, 2019} {© 2019 Patrick Stanford pat@coviana.com} {Licensed under the GNU Lesser General Public License} {This is intended to be run as a worksheet script and to} {return the first component number that has the function} {indicated by the integer values below} {That retuned component number can then be used to lookup} {the ComponentName.} {Run using a WS call of =RunScript(ComponentIndex,1) to return} {the component number of the Load-Bearing component.} {Pass the values below to the WSScript to get the componet with that function 0 - Other 1 - Load-Bearing 2 - Insulation 3 - Inner Finish 4 - Outer Finish 5 - Air Gap } Var WallH:Handle; B1:Boolean; NumComponents,N2:Integer; ComponentFunction:Integer; ThisFunction:Integer; Begin WallH:=WSScript_GetObject; ComponentFunction:=WSScript_GetPrmInt(0); B1:=GetNumberOfComponents(WallH,NumComponents); For N2:= 1 to NumComponents do Begin B1:=GetComponentFunction(WallH,N2,ThisFunction); If (ThisFunction=ComponentFunction) then WSScript_SetResInt(N2); End; End; Run(ComponentIndex); 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.