Closed emersonbottero closed 4 years ago
I did an extension for now, But it is in SwDocument. Couldn't check if Dimenstions.any(... it breaks the code too.
public static bool SetDimentionValue(this SwDocument doc, string DimentionName, double Value)
{
if (doc == null)
{
Debug.Print($"Can't set a dimention of a document with null reference");
return false;
}
else if ((Dimension)(doc.Model).Parameter(DimentionName) != null)
{
doc.Dimensions[DimentionName].SetValue(Value);
return true;
}
Debug.Print($"Dimention {DimentionName} not found in Model {doc.Title}");
return false;
}
I like the idea with TrySetValue/TryGetValue, trying to make it more consistent with IDictionary, i.e. exception if key does not exist (i.e. dimension is not present)
bool TrySetValue(string dimName, double val)
We can add it to the extension method of IXDimensionRepository. It is similar to IXPropertyRepositoryExtension::Set
Implemented in the preview builds to be merged into release
Merged to release:
IXDimensionRepository.TrySetDimensionValue IXDimensionRepository.TryGetDimensionValue
I Think mPart.Dimensions["A@Extrude1"]?.SetValue(Dimentions.Asize) should not break the code when there is no "A@Extrude1" in the model, or if it is really necessary we could have a mPart.Dimensions["A@Extrude1"]?.TrySetValue(Dimentions.Asize) that fails silently. Or return an bool informing if it worked or not.