Window doesn't cut through wall

Window doesn't cut through wall

supportS8CPF
Explorer Explorer
2,330 Views
6 Replies
Message 1 of 7

Window doesn't cut through wall

supportS8CPF
Explorer
Explorer

I am placing a window via the .NET API using the NewFamilyInstance() method via the code:
 document.Create.NewFamilyInstance(new XYZ(X, Y, Z), symbol, wall, doc.GetElement(wall.LevelId) as Level, StructuralType.Beam);.
However the window does not cut through the wall(see image included). However, after the window is placed, changing the "Sill Height" manually(see image included), the window does cut through the wall.

 

I have tried adding Document.Regenerate() before calling Transaction.Transmit(),

tried to change the Sill Height in code, tried flipping the window twice, as per suggestions in existing similar issues in this Forum, but to not avail.

What might be the issue?

 

0 Likes
2,331 Views
6 Replies
Replies (6)
Message 2 of 7

Speed_CAD
Collaborator
Collaborator

Hi,

 

I think the experts on the forum could help you better if you put some of your code, so they can test or see if there is something missing. Anyway, I ask you, when you insert the instance with the NewFamilyInstance method, do you pass the Host of the window as an argument?

Mauricio Jorquera
0 Likes
Message 3 of 7

scgq425
Advocate
Advocate

Hi , This Problem is u window location Point is not at wall location Curve , this problem will set this error , you can calcuate the point base window_location_curve to verify this point .

LanHui Xu 徐兰辉
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

Blog
LinkedIn
Revit/CAD Development | Steel Product Manager

EESignature

0 Likes
Message 4 of 7

supportS8CPF
Explorer
Explorer
Hi,

I have updated my question with code.
Yes I do pass the wall as host in the method.

Festim
0 Likes
Message 5 of 7

supportS8CPF
Explorer
Explorer

I am not sure I understand. Can you please elaborate?

0 Likes
Message 6 of 7

Speed_CAD
Collaborator
Collaborator

Hi,

 

Here is the code if you want to review it, there is no error handling.

 

Reference reference = uidoc.Selection.PickObject(Autodesk.Revit.UI.Selection.ObjectType.Element);
Wall wall = (Wall)doc.GetElement(reference.ElementId);

LocationCurve location = (LocationCurve)wall.Location;
Curve curve = location.Curve;
XYZ p1 = curve.GetEndPoint(0);
XYZ p2 = curve.GetEndPoint(1);
XYZ midPoint = (p1 + p2) / 2;

FamilySymbol familySymbol = new FilteredElementCollector(doc).OfClass(typeof(FamilySymbol))
                                    .WhereElementIsElementType()
                                        .Cast<FamilySymbol>()
                                            .First(x => x.Name == "0406 x 0610mm");

using (Transaction tr = new Transaction(doc, "Insert Window"))
{
    tr.Start();

    if (!familySymbol.IsActive)
        familySymbol.Activate();

    FamilyInstance familyInstance = doc.Create.NewFamilyInstance(midPoint,
        familySymbol,
        wall,
        (Level)doc.GetElement(wall.LevelId), StructuralType.NonStructural);
    Parameter parameter = familyInstance.get_Parameter(BuiltInParameter.INSTANCE_SILL_HEIGHT_PARAM);
    parameter?.Set(UnitUtils.ConvertToInternalUnits(500, UnitTypeId.Millimeters));

    tr.Commit();
}

 

Mauricio Jorquera
0 Likes
Message 7 of 7

TheRevitWizard
Participant
Participant

Hi @supportS8CPF Things to keep in mind.

--> Make Sure the Point is on the window's Location Curve.(You can get it by getting the midpoint using Endpoint(0&1)
--> As per the method u posted i can see u trying to set structuralType.Beam, Keep it as StructuralType.NonStructural

And for your reference here Mr. @Speed_CAD posted the complete code which will certainly solve your issue.

bharatminocha1_0-1707730523652.png

 


All the very Best
Regards,
BM

0 Likes