0 Members and 1 Guest are viewing this topic.
public static double? GetAutoLength(this Item item) { var lengthDim = item.GetDimension("Length"); if (lengthDim is not ItemComboDimension lengthComboDim) return null; if (lengthComboDim.SelectedOption == "Auto") return lengthDim.Value; return GetSpecBasedAutoLength(); }
var item = mapper.From<Item>(lineItem); if (item.CID != 866) yield break; var autoLength = item.GetAutoLength(); if (autoLength.IsSuccess) yield break; var materialWidth = item.GetMaterialWidth(true); var connectorAllowance = item.GetConnectorAllowance(); var length = item.GetDimensionValue("length"); if (materialWidth.IsError || connectorAllowance.IsError || length.IsError) yield break; var netLength = materialWidth - connectorAllowance; if (Math.Abs(length - netLength) > MinimumDifference) yield break;
public static Outcome<double> GetAutoLength(this Item item) { var lengthDim = item.GetDimension("length"); if (lengthDim.IsError) return lengthDim.Error; if (lengthDim.Value is not ItemComboDimension lengthComboDim) return new Error("No length combo box dimension"); if (lengthComboDim.SelectedOption != "Auto") return new Error("Length dimension was not set to auto."); return lengthComboDim.Value; }
public static Outcome<double> GetMaterialWidth(this Item item, bool addBuffer = false) { var length = item.Gauge is not MachineGauge machineGauge ? null : machineGauge.FlatBedSizes.FirstOrDefault()?.Width; if (length is null) return new Error("Could not get a material width from the gauge."); const double buffer = 0.125; return addBuffer ? (double)length + buffer : (double)length; }
select item.cidcase 866 if item.dim[3].numvalue >= 1395 and item.dim[3].numvalue <= 1450 then item.dim[3].value = "Auto" item.dim[3].locked = false end ifitem.update()end select
I've tried doing a lot of crazy stuff to try to get at what the value for "Auto" would eventually be, including crawling the spec tables and I've tried briefly setting the item's length to "Auto", updating, getting the resulting double, and setting it back.The latter actually worked but it is quite the hack and I'm not a very big fan of that, although it did highlight to me that I'll need to build out something as a sort of transaction system. So maybe I'll work on that first.
There is nothing wrong with this. It is the path of least resistance, and likely the most accurate. It’s is how I have been doing it, and is a standard practice for AutoCAD API stuff in general. Knowing the turnovers and material width is also very useful and applicable here.
I think my chief concern outside of some ethereal "Well it just doesn't feel right, bro", is that I am concerned about side effects. I don't want to perform manipulations on the data that was curated by detailing or the shop that weren't intentional. In this case, it's investigative. In my mind, if a bunch of stuff broke because I temporarily changed the part, I did not want to have to answer for that. It would sound pretty bad, you have to admit. I hope that makes sense.
Just doing a little QA/QC routine and I want to write something that determines if some duct is longer than what it would be if it were set to "Auto".
I'm hoping to build something that assumes less and *could* be used for other straight types in the future too. Round duct, piping, whatever.
From here, the question is how to present it to the user. There's some history to this. What the inputters had before I started this was a lot of scripts that "just took care of it". This is good in some ways, but it does not enable them to grow in the role or take ownership of the process. I wanted to give the "easiness" of the scripts and also enable the users.So instead of automatically fixing anything, on opening the AddIn, they are presented with a list of items that have suggested adjustments. They come in varying urgency levels like "Suggestion, Warning, Critical", much like a log system.But it actually tells them, item by item, what the rule was that was flagged. Why it was flagged. And what the system will do to fix it, or what they can do to fix it.
When I'm implementing the QA/QC process in Revit, I think I will be feeling much more flexible in the approach to all of this. Since we're trying to allow inputters to do what inputters do within the environment best fits their purpose, I was essentially stuck with finding a way to make CAMduct handle it.