Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Window doesn't cut through wall

6 REPLIES 6
Reply
Message 1 of 7
supportS8CPF
471 Views, 6 Replies

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

Window doesn't cut through wall

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?

 

Labels (2)
6 REPLIES 6
Message 2 of 7
Speed_CAD
in reply to: supportS8CPF

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

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
Message 3 of 7
scgq425
in reply to: supportS8CPF

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 .

0 Likes

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 .

Message 4 of 7
supportS8CPF
in reply to: Speed_CAD

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

Hi,

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

Festim
Message 5 of 7
supportS8CPF
in reply to: scgq425

supportS8CPF
Explorer
Explorer

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

0 Likes

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

Message 6 of 7
Speed_CAD
in reply to: supportS8CPF

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

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
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

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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report