Jump to content

Material Density reporting


Recommended Posts

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. 

Screenshot2023-10-30at13_07_14.thumb.png.3e921c7c161b411df1a97fdac054a8ec.png

 

Screenshot2023-10-30at13_07_41.thumb.png.9426e207bcf81efddb36b68a6667ab9d.png

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 by markdd
Link to comment
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"?

Link to comment

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

  • Like 2
Link to comment

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.

  • Like 1
Link to comment
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...

Link to comment

@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.

Link to comment
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.

Link to comment

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...