Using LookupParameter().Set() causing inconsistent changes to outside and inside diameters

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:
1 inch pipe

Here is how it looks when I set it to 1/2":
half in error measurements
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:
half in normal visual

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.

half in error

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:

sizeParameter = s.get_Parameter(BuiltInParameter.RBS_PIPE_DIAMETER_PARAM)
sizeParameter.Set(pipeSizes.get(size))

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…

This is how I’m selecting the size.

pipeSizes = {"1/2\"" : 0.0416666,
             "3/4\"" : 0.0625,
             "1\"" : 0.0833333333,
             "1 1/4\"" : 0.10416666,
             "1 1/2\"" : 0.125,
             "2\"" : 0.1666666}

pipeKeys = ["1/2\"",
             "3/4\"",
             "1\"",
             "1 1/4\"",
             "1 1/2\"",
             "2\""]

size = forms.SelectFromList.show(pipeKeys, button_name="Select Pipe Size", multiselect=False)

I tried to get the associated parameter for connectors but couldn’t get it, so I just tried setting the connector radius and it worked.

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.

pipeSizes = {"1/2\"" : 0.0416666667,
             "3/4\"" : 0.0625,
             "1\"" : 0.0833333333,
             "1 1/4\"" : 0.1041666667,
             "1 1/2\"" : 0.125,
             "2\"" : 0.1666666667}

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?