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?
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?
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?
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?
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 .
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 .
I am not sure I understand. Can you please elaborate?
I am not sure I understand. Can you please elaborate?
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();
}
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();
}
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.
All the very Best
Regards,
BM
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.
All the very Best
Regards,
BM
Can't find what you're looking for? Ask the community or share your knowledge.