How to Revit 2016 api Create Dimension between Grid

How to Revit 2016 api Create Dimension between Grid

Anonymous
Not applicable
3,059 Views
5 Replies
Message 1 of 6

How to Revit 2016 api Create Dimension between Grid

Anonymous
Not applicable

on Revit 2014,my program ok,but on Revit 2016,it's give me a error,I search web along time,have not find the Reason

8b728c5589d31173d2e4d40429940595.png

 

Main code
====================================
ReferenceArray refArray = new ReferenceArray();//分尺寸
foreach (ElementId e in eSet)
{
if (doc.GetElement(e).GetType() == typeof(Grid))
{
Grid gr = doc.GetElement(e) as Grid;
Curve cv = gr.Curve;
refArray.Append(cv.Reference);
}
}

if (!doc.IsFamilyDocument)
{
doc.Create.NewDimension(doc.ActiveView, line, refArray);//分尺寸
}
else
{
doc.FamilyCreate.NewDimension(doc.ActiveView, line, refArray);//分尺寸
}
====================================

 

0 Likes
3,060 Views
5 Replies
Replies (5)
Message 2 of 6

Charles.Piro
Advisor
Advisor

Hello,

 

how you create the "line" ?

 

 



PIRO Charles
Developer

PIRO CIE
Linkedin


0 Likes
Message 3 of 6

Anonymous
Not applicable

The "line"'s start point is pick a point(snap on a Grid point),end point Calculation by start point,Increasing along the X axis.

 thinks.

 

0 Likes
Message 4 of 6

jeremytammik
Autodesk
Autodesk

Dear cao2013,

 

Have you debugged your code?

 

If not, please do.

 

The answer is probably quite simple.

 

Nobody but you can debug your code without a full and really minimal reproducible case to examine:

 

http://thebuildingcoder.typepad.com/blog/about-the-author.html#1b

 

Best regards,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 5 of 6

boostyourbim
Advocate
Advocate
In 2016, get the grid reference for dimensioning like this

Reference gridRef = null;
Options opt = new Options();
opt.ComputeReferences = true;
opt.IncludeNonVisibleObjects = true;
opt.View = doc.ActiveView;
foreach (GeometryObject obj in grid.get_Geometry(opt))
{
if (obj is Line)
{
Line line = obj as Line;
gridRef = line.Reference;
}
}
Message 6 of 6

dnenovMXKU9
Enthusiast
Enthusiast

Great answer! Thanks a lot.

0 Likes