markdd Posted October 30, 2023 Share Posted October 30, 2023 (edited) I thought I would experiment with using a Material to calculate the weight of an object. Assuming that the weight of an object is it's Volume multiplied by it's Density, then it should be possible to use the Density property of a material to get the correct answer. I have a cube that has a volume of 1 cubic meter and I am using the Metal Aluminium material. I cannot get the density to show up in the worksheet. I am sure I am doing something wrong, but don't know what! If anybody can offer some guidance I would be grateful. Enclosed is the file. Mass of a Cube.vwx Many thanks Mark Edited October 30, 2023 by markdd Quote Link to comment
Tom W. Posted October 30, 2023 Share Posted October 30, 2023 Does the 'Metal Aluminium Anodized MT' Material definitely have data entered for Density? I don't have that material in my libraries so can't check but it works fine with 'Aluminium (UK) MT' for example. Quote Link to comment
markdd Posted October 30, 2023 Author Share Posted October 30, 2023 Hi - Yes. Here is the file. Mass of a Cube.vwx Quote Link to comment
markdd Posted October 30, 2023 Author Share Posted October 30, 2023 19 minutes ago, Tom W. said: but it works fine with 'Aluminium (UK) MT' for example. It would be good to see your workings. I feel sure there is something simple that I have missed. Quote Link to comment
Tom W. Posted October 30, 2023 Share Posted October 30, 2023 When you change the criteria to 'Type Is Material' the formula works... Quote Link to comment
markdd Posted October 30, 2023 Author Share Posted October 30, 2023 1 minute ago, Tom W. said: When you change the criteria to 'Type Is Material' the formula works... Thanks. I was afraid you were going to say that! Does that mean that material properties are not possible if the search criteria is anything other than "Type is Material"? Quote Link to comment
Tom W. Posted October 30, 2023 Share Posted October 30, 2023 I think yes because it needs to find the Material resource but @Nikolay Zhelyazkov will be able to explain better! Quote Link to comment
Pat Stanford Posted October 30, 2023 Share Posted October 30, 2023 Tom W. is on the right track. The database is of objects. The MaterialProperty function is expecting a handle to a Material and you are giving it a handle to an object. Use MatPropertyByName that lets you specify both the material Name and the Material Property you want. Combined with MaterialName and you get the density for the material associated to that object. =MATPROPERTYBYNAME(MATERIALNAME, 'materialdensity') The full developer function reference for worksheets is available at https://developer.vectorworks.net/index.php?title=Worksheet_Functions#Material 2 Quote Link to comment
markdd Posted October 30, 2023 Author Share Posted October 30, 2023 @Pat Stanford Many thanks. My thinking was that the Material was more of an attribute and therefore I would be able to extract the Material information in the same way that you can a Fill attribute or a Texture resource. In fact, it is much more like an object or a Symbol resource. Quote Link to comment
Pat Stanford Posted October 30, 2023 Share Posted October 30, 2023 I think of it slightly differently. VW has a concept of "Parent" objects or "Container" objects. Thinks like Symbols, Groups, Viewports, even Layers. These are all "objects" that can contain other objects. I think that by applying a Material, you are effectively converting whatever object the material is applied to to a "Container". So if you only have the handle to the container you will need to dig deeper to get the material. I hope that makes sense. 1 Quote Link to comment
markdd Posted October 30, 2023 Author Share Posted October 30, 2023 2 minutes ago, Pat Stanford said: I hope that makes sense. That's great. Many thanks Mark Quote Link to comment
Tom W. Posted October 30, 2023 Share Posted October 30, 2023 2 hours ago, Pat Stanford said: I think of it slightly differently. VW has a concept of "Parent" objects or "Container" objects. Thinks like Symbols, Groups, Viewports, even Layers. These are all "objects" that can contain other objects. I think that by applying a Material, you are effectively converting whatever object the material is applied to to a "Container". So if you only have the handle to the container you will need to dig deeper to get the material. I hope that makes sense. Hmmm I think the function is looking for the Material resource + doesn't care whether it's applied to an object or not. MaterialName + MaterialVolume are returning values derived from the object, whereas MaterialProperty is returning a value derived from the Material resource, hence you need to present the function with a resource + that could be any resource: in Mark's worksheet you could use MatPropertyByName(materialName, propertyName) + choose a different Material to the one applied to his cube (i.e. a Material in the Resource Manager but not one applied to any objects) + it will still return that Material's density, even though the report is looking for CSG Solids... Quote Link to comment
Pat Stanford Posted October 30, 2023 Share Posted October 30, 2023 @Tom W. You are correct. You could pass any Material Name to the MatPropertyByName function and get the value from there. That is why I uses the MaterialName function to get the material assigned to the object so you return the correct material. The material is effectively a "child" (or "contained") by the CGS object. You need the MaterialName function to figure out what that material is so you can get the correct properties from it. Quote Link to comment
markdd Posted October 30, 2023 Author Share Posted October 30, 2023 Just now, Pat Stanford said: You are correct. You could pass any Material Name to the MatPropertyByName function and get the value from there. That is why I uses the MaterialName function to get the material assigned to the object so you return the correct material. This is the way to do what I needed to do and it works well. The MaterialProperty function only works when I have the Critertia set to Material. I am sure that's what was intended by developers. Quote Link to comment
Tismacfan. Posted December 2, 2024 Share Posted December 2, 2024 Do you also know how to calculate the weight of an object made of a compound material, where the densities of both materials are known: Quote Link to comment
Tom W. Posted December 2, 2024 Share Posted December 2, 2024 2 hours ago, Tismacfan. said: Do you also know how to calculate the weight of an object made of a compound material, where the densities of both materials are known: Just report on each Simple Material individually then add the values together. So for each Material return the density + the volume then multiply them together then add the results from both Materials together. Quote Link to comment
Tismacfan. Posted December 3, 2024 Share Posted December 3, 2024 Okay, but if I want to retrieve the name of the material in a column, I get all three materials: Material 1 + Material 2 + the name of the compound material. However, I only want to see the name of the compound material in my worksheet, with its weight calculated next to it. The weight should include the combined weight of Material 1 and Material 2. Quote Link to comment
Tom W. Posted December 3, 2024 Share Posted December 3, 2024 I would do it using spreadsheet cells rather than a database. Do you know how to do this? Paste the name of the Material in the first cell in the row then the formulas to return density + volume in subsequent cells. Then multiply those two cells in the next cell. Copy + paste to row below. There is a preformatted spreadsheet report in libraries you can adapt if necessary. 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.