I have a script that is changing pipe size based on user input. I’m developing it for instances where users want to change pipe that contains accessories which will disable the size input in the option bar.
I have a prototype working but while testing it I noticed that on SOME pipe sizes it is changing the “Outside Diameter” and “Inside Diameter” to be the diameter as well. It should be taking into account the pipe thickness and it is causing the model to be off.
Here is how the measurements should look:
Here is how it looks when I set it to 1/2":
And this is what it causes to the pipe. It should be the same size as the fitting. The pipe on the right has not been corrected while the one on the left has been manually set to 1/2" after the script ran:
Right now I’ve noticed that this is happening to every size I have scripted for except 3/4" and 1".
This is happening with multiple routing preferences. I’m also getting errors with elbows when trying to set it to 1/2" even with routing that includes 1/2" pipe. The error happens, but the elbow seems to be resized fine.
Here is the code I’ve been using to resize:
t = Transaction(doc, "pyRevit - Change Pipe Size")
t.Start()
for s in selection:
if s.ToString() == "Autodesk.Revit.DB.Plumbing.Pipe":
s.LookupParameter("Diameter").Set(pipeSizes.get(size))
elif s.ToString() == "Autodesk.Revit.DB.FamilyInstance":
conn = s.MEPModel.ConnectorManager.Connectors
for c in conn:
c.Radius = (pipeSizes.get(size) /2)
t.Commit()
I’ve also tried using builtinparameter and got the same results:
pipe diameter likely decimal feet. you don’t show what pipeSizes.get(size) is providing
I’ve never seen a fitting resized using the connector directly like that instead of by changing a parameter in the family that is associated with the connector…
Ok, so I found this post and one of the options was just being more precise with their conversion so I thought I’d try that as well since it looked easier than the other option and it appears to have worked.
Below is my new dictionary. It explains why 3/4" and 1" worked. 3/4" terminates after a few digits and the value I had for 1" was already enough digits for Revit’s liking. I assume 1 1/2" worked I just must have missed testing that. Now I have all the non-terminating decimals extended to the same number of digits.
Side note: I thought real numbers terminated but I guess it also includes number that begin to repeat the same finite sequence of digits. Is there different terms for terminating and non-terminating real numbers?