matteoluigi Posted March 24, 2021 Share Posted March 24, 2021 (edited) just a simple question: I want to scan object styles. for example "BA-I-BST-370-230-BFT" contains the letters *BST* in a worksheet I would write sth like =if('stylename'='*BST'; yes;no) in Python I tried (running in a foreach-procedure, it has to filter all slab styles, which names contain the letters BST): (i read somewhere that '.+' is the Asterisk equal for python) if outValue == ('.+BST.+'): however, it doesn't filter work, why? Edited March 24, 2021 by matteoluigi Quote Link to comment
JBenghiat Posted March 24, 2021 Share Posted March 24, 2021 You’re thinking of a regex string, which still needs a function call in python. Do a web search for python strings. You should be able to find a substring call. I believe the keyword “in” will work as well (“BST” in outValue). 1 Quote Link to comment
Nicolas Goutte Posted March 24, 2021 Share Posted March 24, 2021 (edited) 39 minutes ago, matteoluigi said: in Python I tried (running in a foreach-procedure, it has to filter all slab styles, which names contain the letters BST): (i read somewhere that '.+' is the Asterisk equal for python) if outValue == ('.+BST.+'): however, it doesn't filter work, why? If you want to use regular expressions, you have to use explicitly the module "re", the one handling regular expressions: https://docs.python.org/3.8/library/re.html Be careful that in regular expressions .+ means "at least one character", which might not what you seem to want. Edited March 24, 2021 by Nicolas Goutte 1 Quote Link to comment
matteoluigi Posted March 25, 2021 Author Share Posted March 25, 2021 14 hours ago, Nicolas Goutte said: If you want to use regular expressions, you have to use explicitly the module "re" that's to complicated, I solved it with a substring (of course the letters 'ABB', 'BST' or 'NEU' always appear at the third place in the stylename which has to be separated by '-' 😉) Quote ok, outValue, outType, outMap = vs.IFC_GetPsetProp2((HNDL),'IfcBeam','Name') Style = vs.SubString(outValue, '-', 3) if Style == 'BST': ....... Quote Link to comment
Tobias Döngi Posted March 25, 2021 Share Posted March 25, 2021 (edited) You can achieve that easily by writing "if 'BST' in outvalue:" As long as it's okay that the string can be at any position in outValue. Edited March 25, 2021 by Tobias Döngi 1 Quote Link to comment
matteoluigi Posted March 25, 2021 Author Share Posted March 25, 2021 1 minute ago, Tobias Döngi said: As long as it's okay that the string can be at any position in outValue. otherwise I can use a substring-function before :-), thanks! 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.