Inconsistent Z Value in XYZ Position of NewFamilyInstance

Inconsistent Z Value in XYZ Position of NewFamilyInstance

yuvdal
Enthusiast Enthusiast
686 Views
9 Replies
Message 1 of 10

Inconsistent Z Value in XYZ Position of NewFamilyInstance

yuvdal
Enthusiast
Enthusiast

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

 

Accepted solutions (1)
687 Views
9 Replies
Replies (9)
Message 2 of 10

RPTHOMAS108
Mentor
Mentor

Do you find that offset of 19.05mm represented elsewhere?

 

 

Message 3 of 10

mhannonQ65N2
Collaborator
Collaborator

Does your pipe have a radius or diameter of 3/4"? That value seems like it comes from the geometry of one (or more) of the involved elements.

0 Likes
Message 4 of 10

yuvdal
Enthusiast
Enthusiast
I tried now that the family of the void would be the simplest when its shape is square without any radius and I still get an offset of 3/4" so it is probably not related to that.
0 Likes
Message 5 of 10

yuvdal
Enthusiast
Enthusiast
I searched a lot but unfortunately, I couldn't find where it is represented
0 Likes
Message 6 of 10

RPTHOMAS108
Mentor
Mentor

Could you shared a copy of the family or cut down version of it?

0 Likes
Message 7 of 10

yuvdal
Enthusiast
Enthusiast

Attached a copy of the family

0 Likes
Message 8 of 10

BenoitE&A
Collaborator
Collaborator

Have you checked the parameter INSTANCE_ELEVATION_PARAM, usually people create a default value?

The other possible issue that I see is the topic of the georeferencement. In my memory Revit deals with that creating an additionnal transformation. In effects, you create your model in the local coordinates than georeference your model so Revit applies a global Transform to all the coordinates to put you in the right position.  


Benoit FAVRE
CEO of etudes & automates
www.etudesetautomates.com/
0 Likes
Message 9 of 10

RPTHOMAS108
Mentor
Mentor
Accepted solution

@BenoitE&A is correct this is related to the offset parameter but also related to the Level it is using to offset from.

 

It is probably better to use the overload that specifies the level as otherwise it isn't easy to determine what level was used to offset the instance from. You could probably also specify the level parameter after creating the instance.

 

What tends to happen when you don't provide a level (for this wall based template) is that the level is often taken from the level nearest to the bottom of the wall but that level may not be one that the Wall is constrained to.

 

As an example the wall below has a 'Base Constraint' of 'Level 2' with a base level offset of -3900. However the family you place will be offset from 'Level 1'. Since 'Level 1' is neither the top or bottom constraint of the wall it is hard to know that it relates to the wall in terms of your family instance placement.230208a.PNG

The location point you specify has it's Z value ignored. Therefore the offset required is  (desired Z value) - (Level Elevation). You can add the offset in the same transaction used to create the family instance:

 

        Using tx As New Transaction(IntDoc, "Line at origin")
            If tx.Start = TransactionStatus.Started Then
                If FS.IsActive = False Then
                    FS.Activate()
                End If

                Dim FI As FamilyInstance =
                    IntDoc.Create.NewFamilyInstance(CE.GeometryCurve.GetEndPoint(0), FS, _
WL, Lv, StructuralType.NonStructural)

                Dim P As Parameter = FI.Parameter(BuiltInParameter.INSTANCE_ELEVATION_PARAM)
                P.Set(Offset)

                tx.Commit()
            End If
        End Using

 

Within your family the horizontal reference plane on elevation has no effect. The basic wall based family template will offset from the level.

 

 

Message 10 of 10

yuvdal
Enthusiast
Enthusiast

This is exactly the solution!

Thanks a lot 🙂 @RPTHOMAS108  @BenoitE&A 

0 Likes