Error to create FabricSheet

Error to create FabricSheet

WillianMayrink
Participant Participant
152 Views
0 Replies
Message 1 of 1

Error to create FabricSheet

WillianMayrink
Participant
Participant

I've encountered an issue with creating FabricSheets in certain walls in my Revit project. Despite being able to create the same FabricSheet in multiple walls, I'm receiving an error when attempting to do so in specific walls.

 

WillianMayrink_1-1711373594006.png

 

 

However, after manually inserting a FabricSheet into one of these problematic walls:

WillianMayrink_2-1711373700515.png

 

I'm able to run the same code successfully without any errors.

 

WillianMayrink_3-1711373966155.png

 

I've tried examining the wall properties in Revit DB Explorer, but I haven't been able to identify any differences that might be causing the issue.


This is my code:

public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
    Document doc = commandData.Application.ActiveUIDocument.Document;
    
    var openingWindow = doc.GetElement(new ElementId(6855434)) as FamilyInstance;
    var wall = openingWindow.Host as Wall;

    var lengthWindow = openingWindow.Symbol.GetParameters("Comprimento")[0].AsDouble();
    var locationPointOpening = ((LocationPoint)openingWindow.Location).Point;
    var orientationOpening = openingWindow.HandOrientation.Normalize();

    var pointToInsertFabricSheet = Transform.CreateTranslation(-orientationOpening.Multiply(lengthWindow / 2)).OfPoint(locationPointOpening);
    using (Transaction t = new Transaction(doc, "Create Fabric Sheet"))
    {
        try
        {
            t.Start();
            var fabricSheetType = doc.GetElement(new ElementId(7082324));
            double width = fabricSheetType.get_Parameter(BuiltInParameter.FABRIC_SHEET_OVERALL_WIDTH).AsDouble();
            double length = fabricSheetType.get_Parameter(BuiltInParameter.FABRIC_SHEET_OVERALL_LENGTH).AsDouble();

            var pointAux = Transform.CreateTranslation(orientationOpening.Multiply(length / 2)).OfPoint(pointToInsertFabricSheet);
            Transform transform = Transform.Identity;
            transform.BasisY = XYZ.BasisZ;
            transform.BasisZ = wall.Orientation;
            transform.BasisX = -orientationOpening;
            transform.Origin = Transform.CreateTranslation(-XYZ.BasisZ.Multiply(width / 2)).OfPoint(pointAux);
            var fabricSheetCreated = FabricSheet.Create(doc, wall, fabricSheetType.Id);
            fabricSheetCreated.CoverOffset = wall.Width / 2;
            fabricSheetCreated.PlaceInHost(wall, transform);
            t.Commit();
        }
        catch (Exception e)
        {
            if (t.HasStarted())
                t.RollBack();
            throw e;
        }
    }

    TaskDialog.Show("Dialog", "FabricSheet created successfully.");
    return Result.Succeeded;
}


Does anyone have some idea?

Thanks in advance.

0 Likes
153 Views
0 Replies
Replies (0)