Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to Revit 2016 api Create Dimension between Grid

5 REPLIES 5
Reply
Message 1 of 6
cao2013
2444 Views, 5 Replies

How to Revit 2016 api Create Dimension between Grid

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);//分尺寸
}
====================================

 

5 REPLIES 5
Message 2 of 6
Charles.Piro
in reply to: cao2013

Hello,

 

how you create the "line" ?

 

 



PIRO Charles
Developer

PIRO CIE
Linkedin


Message 3 of 6
cao2013
in reply to: Charles.Piro

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.

 

Message 4 of 6
jeremytammik
in reply to: cao2013

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

Message 5 of 6
boostyourbim
in reply to: cao2013

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
in reply to: boostyourbim

Great answer! Thanks a lot.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community