Description
For the string assignment in build123d:
In [5]: b1 = Box(1, 1, 1)
...: b1.material = "Stainless 304"
I thought of using pymat.search.
I need a way to uniquely find a material.
Problem Statement
If I want the "normal "Stainless Steel", I get back all of them, and can't easily narrow down besides filtering
In [23]: m = pymat.search("Stainless Steel")
In [24]: m
Out[24]:
[Material('stainless', ρ=8.0 g/cm³),
Material('stainless.s303', ρ=8.0 g/cm³),
Material('stainless.s304', ρ=8.0 g/cm³),
Material('stainless.s316L', ρ=8.0 g/cm³),
Material('stainless.s17_4PH', ρ=7.8 g/cm³),
Material('stainless.s316L.passivated', ρ=8.0 g/cm³),
Material('stainless.s316L.electropolished', ρ=8.0 g/cm³)]
For specif instances it works:
In [25]: m = pymat.search("Stainless Steel 304")
In [26]: m
Out[26]: [Material('stainless.s304', ρ=8.0 g/cm³)]
In [27]: m = pymat.search("Stainless Steel")
In [28]: m
Out[28]:
[Material('stainless', ρ=8.0 g/cm³),
Material('stainless.s303', ρ=8.0 g/cm³),
Material('stainless.s304', ρ=8.0 g/cm³),
Material('stainless.s316L', ρ=8.0 g/cm³),
Material('stainless.s17_4PH', ρ=7.8 g/cm³),
Material('stainless.s316L.passivated', ρ=8.0 g/cm³),
Material('stainless.s316L.electropolished', ρ=8.0 g/cm³)]
Proposed Solution
for example introduce a fuzzy argument with default True:
m = pymat.search("Stainless Steel", fuzzy=False)
Then I can call pymat.search("Stainless Steel", fuzzy=False) If that comes back with one material all good, if no material comes back I can issue pymat.search("Stainless Steel") to get all of them and raise a non-unique error that shows the user all valid names
Alternatives Considered
any better idea appreciated
Additional Context
No response
Impact
No response
Changelog Category
Added
Description
For the string assignment in build123d:
In [5]: b1 = Box(1, 1, 1)
...: b1.material = "Stainless 304"
I thought of using pymat.search.
I need a way to uniquely find a material.
Problem Statement
If I want the "normal "Stainless Steel", I get back all of them, and can't easily narrow down besides filtering
For specif instances it works:
In [25]: m = pymat.search("Stainless Steel 304")
In [26]: m
Out[26]: [Material('stainless.s304', ρ=8.0 g/cm³)]
In [27]: m = pymat.search("Stainless Steel")
In [28]: m
Out[28]:
[Material('stainless', ρ=8.0 g/cm³),
Material('stainless.s303', ρ=8.0 g/cm³),
Material('stainless.s304', ρ=8.0 g/cm³),
Material('stainless.s316L', ρ=8.0 g/cm³),
Material('stainless.s17_4PH', ρ=7.8 g/cm³),
Material('stainless.s316L.passivated', ρ=8.0 g/cm³),
Material('stainless.s316L.electropolished', ρ=8.0 g/cm³)]
Proposed Solution
for example introduce a
fuzzyargument with defaultTrue:Then I can call
pymat.search("Stainless Steel", fuzzy=False)If that comes back with one material all good, if no material comes back I can issuepymat.search("Stainless Steel")to get all of them and raise a non-unique error that shows the user all valid namesAlternatives Considered
any better idea appreciated
Additional Context
No response
Impact
No response
Changelog Category
Added