Editing IfcOpenShell code examples

From Wiki.OSArch

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.

Latest revision Your text
Line 524: Line 524:
 
You can use <code>datetime.time</code> instead of <code>datetime.datetime</code> the same way.
 
You can use <code>datetime.time</code> instead of <code>datetime.datetime</code> the same way.
 
==IfcDuration==
 
==IfcDuration==
[https://standards.buildingsmart.org/IFC/RELEASE/IFC4/ADD2_TC1/HTML/link/ifcduration.htm IfcDuration] is used to store a time interval (eg. time to perform a task) in ISO 8601 format. There is apparently no ready to use standard python module to handle it. It can be handled using regular expressions. For format given as example in IFC documentation :
+
[https://standards.buildingsmart.org/IFC/RELEASE/IFC4/ADD2_TC1/HTML/link/ifcduration.htm IfcDuration] is used to store a time interval (eg. time to perform a task) in ISO 8601 format : PnYnMnDTnHnMnS. There is apparently no ready to use standard python module to handle it. It can be handled using regular expressions.  
 
<syntaxhighlight lang="python">
 
<syntaxhighlight lang="python">
 
>>> import re
 
>>> import re
Line 530: Line 530:
 
('2', '10', '15', '10', '30', '20')
 
('2', '10', '15', '10', '30', '20')
 
</syntaxhighlight>
 
</syntaxhighlight>
 
To handle all available formatting options defined in [https://en.wikipedia.org/wiki/ISO_8601#Durations ISO 8601] a more complex regular expression is required like following.
 
[https://pythex.org/?regex=P(%3F%3A(%3FP%3Cyear%3E%5Cd%2B%3F%5B%2C%5C.%5D%3F%5Cd*)%5BY-%5D)%3F(%3F%3A(%3FP%3Cmonth%3E%5Cd%2B%3F%5B%2C%5C.%5D%3F%5Cd*)%5BM-%5D)%3F(%3F%3A(%3FP%3Cweek%3E%5Cd%2B%3F%5B%2C%5C.%5D%3F%5Cd*)W)%3F(%3F%3A(%3FP%3Cday%3E%5Cd%2B%3F%5B%2C%5C.%5D%3F%5Cd*)D%3F)%3F(%3F%3AT(%3F%3A(%3FP%3Chour%3E%5Cd%2B%3F%5B%2C%5C.%5D%3F%5Cd*)%5BH%3A%5D)%3F(%3F%3A(%3FP%3Cminute%3E%5Cd%2B%3F%5B%2C%5C.%5D%3F%5Cd*)%5BM%3A%5D)%3F(%3F%3A(%3FP%3Csecond%3E%5Cd%2B%3F%5B%2C%5C.%5D%3F%5Cd*)S%3F)%3F)%3F&test_string=P3Y6M4DT12H30M5S%0AP1M%0APT1M%0AP1DT12H%0AP0%2C5Y%0AP0.5Y%0APT36H%0AP1DT12H%0AP0003-06-04T12%3A30%3A05%0AP05Y%0AP0..5Y%0AP0%2C.5Y&ignorecase=0&multiline=0&dotall=0&verbose=0 You can test it on pythex].
 
 
<code>P(?:(?P<year>\d+?[,\.]?\d*)[Y-])?(?:(?P<month>\d+?[,\.]?\d*)[M-])?(?:(?P<week>\d+?[,\.]?\d*)W)?(?:(?P<day>\d+?[,\.]?\d*)D?)?(?:T(?:(?P<hour>\d+?[,\.]?\d*)[H:])?(?:(?P<minute>\d+?[,\.]?\d*)[M:])?(?:(?P<second>\d+?[,\.]?\d*)S?)?)?</code>
 
  
 
==IfcCalendarDate==
 
==IfcCalendarDate==

Please note that all contributions to Wiki.OSArch are considered to be released under the Creative Commons Attribution-ShareAlike (see Wiki.OSArch:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

To edit this page, please answer the question that appears below (more info):

Cancel Editing help (opens in new window)