- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I am currently working on a project in which I am creating a new family instance in Revit. I am using the "NewFamilyInstance" method to create the instance, and I am able to successfully create the instance, however, I have noticed an issue with the Z value of the XYZ position.
Initially, when I create the NewFamilyInstance, the XYZ position is {(7.708333333, 42.334635417, 9.348958333)}, however, after getting the origin of the voidInstance, the value is {(7.708333333, 42.334635417, 9.411458333)}. I would like to understand why there is a difference in the Z value between the two points.
For now, I am using the "Move" method to overcome the issue, but I would like to get rid of it.
I have included a code snippet that demonstrates the issue. If anyone has any ideas or suggestions on how to resolve this, I would greatly appreciate it.
Thank you for your time and help.
Best regards,
Yuval
//Get the origin point of MEP element in order to place and align
XYZ mepOrigin = mepElement.Element.Location.GetOrigin();
mepOrigin = ModifyBoundingBoxUtils.TransformPointByLink(mepOrigin, mepElement.LinkInstance); // the value is {(7.708333333, 42.334635417, 9.348958333)}
//Activate in order to be able to create the family
if (!_voidFamilySymbol.IsActive)
{
_voidFamilySymbol.Activate();
doc.Regenerate();
}
Wall intersectingWall = intersectingWalls.FirstOrDefault();
//Create the family inside the wall
voidInstance = doc.Create.NewFamilyInstance(mepOrigin, _voidFamilySymbol, intersectingWall, StructuralType.NonStructural);
doc.Regenerate();
//Align the new element with the mep element
XYZ voidOrigin = voidInstance.Location.GetOrigin(); // the value is {(7.708333333, 42.334635417, 9.411458333)}
//Subtract the void origin from the mep origin
XYZ differencePoint = new XYZ(mepOrigin.X - voidOrigin.X, mepOrigin.Y - voidOrigin.Y, mepOrigin.Z - voidOrigin.Z);
//Move the void by the calculated difference
voidInstance.Location.Move(new XYZ(differencePoint.X, differencePoint.Y, differencePoint.Z));
Solved! Go to Solution.