70002153 I wish I could know the unit type of a unit xproperty of a product

Article 70002153
Type Wish
Product vdIFC
Version 9003
Date Added 2/7/2022 12:00:00 AM
Fixed 10.1001.0.1 (2/8/2022 12:00:00 AM)
Submitted by Yannis Makarounis

Summary

I wish I could know the unit type of a unit xproperty of a product

Solution

In version 10.1001.1.0 a new object type vdIFC.vdXPropertyIFCQuantity was added
inherits the vdXproperty type with an additional property UnitType
Quantity properties are added to the PropertiesGroup as vdIFC.vdXPropertyIFCQuantity
and the UnitType is one of the Project.Units
In order to get the value relative to the vdIFCUnit BaseUnitName, that reference the UnitType, you need to multiply the property value with vdIFC.vdXPropertyIFCQuantity.UnitScale

Example:
 //create a new empty IFC Document
vdIFCDocument vdifcdoc = vdIFCComponent1.New(); //Set some properties for the IFC Document project vdifcdoc.Project.Name = "MyProject"; //define the units that we are gooing to use in our properties groups vdifcdoc.Project.Units.AddItem(UnitTypeEnum.LENGTHUNIT, SIUnitName.METRE.ToString(), 0.01);//in centimetrs vdifcdoc.Project.Units.AddItem(UnitTypeEnum.AREAUNIT, SIUnitName.SQUARE_METRE.ToString(), 0.0001);//in square centimeters vdifcdoc.Project.Site.Address = new vdAddress() { Country = "Greece", Region = "Attica", Town = "Glyfada", InternalLocation = "VectorDraw Software Corporation 11 Kyrillou - Methodiou Street" }; //Create a new Bulding and add it to the Buildings collection of the project site vdIFCBuilding building = vdifcdoc.Project.Site.Buildings.Add("Building 1"); //create a new storey and add it to the previous created building vdIFCBuildingStorey storey = building.BuildingStoreys.Add("Ground"); //create an IFC element that represents an ifc wall element type vdIFCProduct mywall = new vdIFCProduct() { Name = "Wall_1", IFCType = vdIFCProduct.IfcElementTypeName.IfcWall.ToString() }; //create a vdRect that represents the wall element grapics vdFigure mywallGraphics = new vdRect() { PenColor = new vdColor(vdColor.ColorType.ByBlock), Width = 10, Height = 0.4, Thickness = 3, HatchProperties = new vdHatchProperties(VectorDraw.Professional.Constants.VdConstFill.VdFillModeSolid) }; //add the graphic representation to the wall product entities mywall.Entities.AddItem(mywallGraphics); //select a color for the wall mywall.PenColor = new vdColor(Color.Brown); //set some properties that will be exported to the ifc file format vdIFCProperties vdprops = mywall.PropertiesGroup.Add("VectorDraw Wall Properties"); vdprops.Properties.AddItem(new vdXPropertyIFCQuantity("Wall_Length",1000.0, UnitTypeEnum.LENGTHUNIT));//in centimeters vdprops.Properties.AddItem(new vdXPropertyIFCQuantity("Wall_Width",40.0, UnitTypeEnum.LENGTHUNIT));//in centimeters vdprops.Properties.AddItem(new vdXPropertyIFCQuantity("Wall_Height",30.0, UnitTypeEnum.LENGTHUNIT));//in centimeters //add the wall to the storey storey.Products.Add(mywall); vdXPropertyIFCQuantity walllength = mywall.PropertiesGroup.FindName("VectorDraw Wall Properties").Properties.FindName("Wall_Length") as vdXPropertyIFCQuantity; double walllength_in_meters = (double)walllength.PropValue * walllength.UnitScale; //Note if the object you create does not have the Building logic for example as simple space area (vdIFCProduct.IfcElementTypeName.IfcSpace) //you can add it to vdifcdoc.Project.Site.Products as follow vdIFCProduct myspace = new vdIFCProduct() { Name = "Space_1", IFCType = vdIFCProduct.IfcElementTypeName.IfcSpace.ToString() }; //create a vdRect that represents the space element grapics vdFigure myspaceGraphics = new vdRect() { PenColor = new vdColor(vdColor.ColorType.ByBlock), InsertionPoint = new gPoint(-5, -10, 0), Width = 20, Height = 20, HatchProperties = new vdHatchProperties(VectorDraw.Professional.Constants.VdConstFill.VdFillModeSolid) }; //add the graphic representation to the space product entities myspace.Entities.AddItem(myspaceGraphics); //select a color for the wall myspace.PenColor = new vdColor(Color.Green); //set some properties that will be exported to the ifc file format vdIFCProperties space_vdprops = myspace.PropertiesGroup.Add("VectorDraw Space Properties"); space_vdprops.Properties.AddItem(new vdXPropertyIFCQuantity("Sapce_Length", 2000.0, UnitTypeEnum.LENGTHUNIT));//in centimeters space_vdprops.Properties.AddItem(new vdXPropertyIFCQuantity("Space_Width",2000.0, UnitTypeEnum.LENGTHUNIT));//in centimeters space_vdprops.Properties.AddItem(new vdXPropertyIFCQuantity("Space_Area",4000000.0, UnitTypeEnum.AREAUNIT));//in square centimeters //add the space to the project Site products vdifcdoc.Project.Site.Products.Add(myspace); vdXPropertyIFCQuantity spacearea = myspace.PropertiesGroup.FindName("VectorDraw Space Properties").Properties.FindName("Space_Area") as vdXPropertyIFCQuantity; double spacearea_in_square_meters = (double)spacearea.PropValue * spacearea.UnitScale;

Send comments on this topic.