質問

I'm creating a wall over a area boundary line, but can't find a way how to place it with Location line "Finish Face: Exterior".

I'm getting geometric data from area boundary:

LocationCurve elLocation = (LocationCurve)area_boundary.Location;
XYZ pt1 = elLocation.Curve.get_EndPoint(0);
XYZ pt2 = elLocation.Curve.get_EndPoint(1);

and then create a line based on it to build a wall:

Line line = doc.Application.Create.NewLineBound(pt1, pt2);
Wall wall = Wall.Create(doc, line, level.Id, false);

This code gives me a wall with Location line and area boundary placed in the centre of it. Is there any way to create wall with Location line coinciding with external area boundary?

Here is an screen-shoot from Revit.

Thank you in advance!

役に立ちましたか?

解決 2

I solved it this way:

  1. Get external face of a wall:

    IList<Reference> sideFaces = HostObjectUtils.GetSideFaces(wall, ShellLayerType.Exterior);
    Face face = uiDoc.Document.GetElement(sideFaces[0]).GetGeometryObjectFromReference(sideFaces[0]) as Face;
    
  2. Get the normal vector of that face and revert it:

    PlanarFace pf = face as PlanarFace;
    XYZ normal_reverted = -1.0 * pf.Normal;
    
  3. Move the wall:

    wall.Location.Move(normal_reverted * (wall.WallType.Width / 2.0));
    

他のヒント

There is a BuiltinParameter for the wall reference key.

Autodesk.Revit.DB.WALL_KEY_REF_PARAM that can be used to set the reference value that would appear against the wall in the wall properties.

However, it is my understanding that programatically the line for the wall will always be the wall centreline when creating the wall. (Somebody is welcome to correct this if they know any better).

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top