Creating Height Dimension for Form

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I am creating an application that needs to create dimension for height of a form. I read Building coders blog and the forum posts and used the sample in SDK folder (Window Wizard). I was able to manage everything well but the following error:
The direction of dimension is invalid.
I tried a lot to solve this issue, but I could not find the solution. Two other peoplehad the same problem in the blog but there is no answer for their questions.I would appreciate if you could help me. Here is the related part of the code:
//The from is created with extrusion command
FaceArray faces =newFaceArray();
if (form.IsSolid)
{
Options options =newOptions();
options.ComputeReferences =true;
IEnumerator<GeometryObject> Objects = form.get_Geometry(options).GetEnumerator();
while (Objects.MoveNext())
{
GeometryObject geoObj = Objects.Current;
if (geoObjisSolid)
{
Solid s = geoObjasSolid;
foreach (Face fcin s.Faces)
{
//Gets the top and bottom face of the form
if (Math.Round((fc.ComputeNormal(newUV(0, 0))).Z) == 1 ||Math.Round((fc.ComputeNormal(newUV(0, 0))).Z) == -1)
{
faces.Append(fc);
}
}
//Here is the line with the error*************************
windowInsetDimension = AddDimension(FamDoc, view3d, faces.get_Item(0), faces.get_Item(1));
}
}
}
publicDimension AddDimension(Document doc, Autodesk.Revit.DB.View3D view,Face face1,Face face2)
{
Dimension dim;
Autodesk.Revit.DB.XYZ startPoint =new Autodesk.Revit.DB.XYZ();
Autodesk.Revit.DB.XYZ endPoint =new Autodesk.Revit.DB.XYZ();
Line line;
Reference ref1;
Reference ref2;
ReferenceArray refArray =newReferenceArray();
PlanarFace pFace1 = face1asPlanarFace;
ref1 = pFace1.Reference;
PlanarFace pFace2 = face2asPlanarFace;
ref2 = pFace2.Reference;
if (null != ref1 &&null != ref2)
{
refArray.Append(ref1);
refArray.Append(ref2);
}
startPoint = pFace1.Origin;
endPoint =new Autodesk.Revit.DB.XYZ(startPoint.X, startPoint.Y, pFace2.Origin.Z);
SubTransaction subTransaction =newSubTransaction(doc);
subTransaction.Start();
line =Line.CreateBound(startPoint, endPoint);
dim = doc.FamilyCreate.NewDimension(view, line, refArray);
subTransaction.Commit();
return dim;
}
Thanks,