« On Creating a Mass from 3D Points | Main | Idling Enhancements and External Events »

March 30, 2012

Comments

Congratulations to the Revit API team for an outstanding release :)

Hello, Jeremy.

In Revit 2013 API added new class - DataStorage - an element which provide storage for entities with any data for whole project. But there are no examples to demonstrate how does it work and how to use it properly.

I think it would be perfect if you explain it.

Best regards, Victor.

Dear Phillip,

Thank you for your appreciation! I forwarded it to the whole team.

Cheers, Jeremy.

Dear Victor,

It should be straightforward enough. Just look at the description of the DataStorage class and the DataStorage.Create method in the Revit API help file RevitAPI.chm.

If you have a minimal sample up and running and any additional interesting insights, I'll happily post them.

Cheers, Jeremy.

Hello, Jeremy.

I've already tried to use it. As I understand, DataStorage is a very simple element which can have one ore more Entity. That was easy to create it. But how can I retrieve entity from DataStorage. I.e. how to get DataStorage from Document?

I think to use FilteredElementCollector to retrieve DataStorage Elements in document. But what if I want to have two ore more DataStorages in document, how can I differ them? Set parameter or additional entity with some unique attribute?

Best regards, Victor.

Dear Victor,

Yes, that thought did cross my mind, or my subconscious, as I was answering you, and in the past as well when looking at this topic...

Thank you for bringing it out into the open.

I guess yes, using a parameter, or the element id, or the unique id. Lots of options. Have a play around with it, let us know what you find out, raise an ADN case if you run into trouble, and we'll publish the result asap, ok?

I mean, for instance, you could simply put a descriptive comment into the 'Comment' parameter and use that to search for it. That should be very simple and foolproof, should work, and you could use regular expressions for complex searches over large numbers of DataStorage elements, if you insist, which I hope you will not :-)

Cheers, Jeremy.

Ok. I'll try to explore features of DataStorage and write a little post about it)

Best regards, Victor.

Hi Jeremy..

I am trying to create NewFamilyInstance using NewFamilyInstance Method (Reference, Line, FamilySymbol) constructor. sample code...

LocationCurve wallCurve = wall.Location as LocationCurve;
XYZ startPt = wallCurve.Curve.get_EndPoint(0);
XYZ endPt = wallCurve.Curve.get_EndPoint(1);
XYZ dir = endPt - startPt;
XYZ cutVec = dir.CrossProduct(XYZ.BasisZ);

ReferencePlane rp = doc.Create.NewReferencePlane(startPt, endPt, cutVec, doc.ActiveView);

famIns = doc.Create.NewFamilyInstance(rp.Reference, Line.get_Bound(startPt, endPt), familySymbol);

Revit shows error "Family cannot be placed on this line as it does not coincide with the input face."

But in Revit 2012, it works fine.
Is there any change in NewRefPlane() or NewFamilyInst() internally in revit 2013?
If any please share any sample..

Thanks..

Dear Sangsen,

Two things strike me here.

1. I don't know whether your NewReferencePlane bubble end, free end and cut vector arguments make sense like that. Are you sure they are appropriate?

2. How does the active view relate to these three points?

I am not aware of any changes, but there have been methods in past API updates whose argument checking was more strictly enforced and thus stopped working as previously, e.g.

http://thebuildingcoder.typepad.com/blog/2010/05/detail-curve-must-indeed-lie-in-plane.html

Cheers, Jeremy.

Hi Jeremy,

First thank you for this wonderful blog.

With the 2012 API I used PipeSizeSettings listPipeSizeSettings = PipeSizeSettings.GetPipeSizeSettings(document) to get the list of PipeSize, but I can not find PipeSizeSettings in 2013 API.

Have you an idea how to do that?

Thank you

Dear Fre,

Thank you for your appreciation!

I think the new routing preferences classes replace the Revit 2012 PipeSizeSettings class.

Look at the RoutingPreferenceTools sample mentioned above:

http://thebuildingcoder.typepad.com/blog/2012/03/new-revit-2013-sdk-samples.html#3

Please let me know how you end replacing your code.

Thank you.

Cheers, Jeremy.

I am having problems with Revit MEP 2013, I can not edit any fire pipes and when ever I try the program just hangs and evntually I have to restart. When I was using Revit MEP 2012 this never happened.

Dear Innocent,

Sorry, to hear that. Sorry, I cannot help. I do not deal with product issues at all.

Cheers, Jeremy.

Dear Jeremy,

I played a little bit with the PreviewControl in a modal Dialog. I changed the orientation of a perspective View3d with a user input (a trackbar) in that PreviewControl but I have problems to redraw the PreviewControl! The changes are only visible after clicking with the mouse on the control and scrolling with the mouse wheel! Is their a possible to redraw the PrieviewControl automatically?

Jörg

Dear Jörg,

Sorry, I have no idea why you should be seeing that kind of behaviour. Never heard of it before. No, there is no way to redraw the control. That should happen automatically. Afaik, your only way to influence it is to dispose of it and re-instantiate a new instance.

By the way, here is the most recent discussion related to this topic:

http://thebuildingcoder.typepad.com/blog/2013/08/issue-using-a-preview-control-in-a-macro.html

Cheers, Jeremy.

I was looking for a list of pipe sizes in a project and thought I would let you know what I used:

private void GetPipeSegmentSizesFromDocument(Document document)
{
FilteredElementCollector collectorPipeType = new FilteredElementCollector(document);
collectorPipeType.OfClass(typeof(Segment));

IEnumerable segments = collectorPipeType.ToElements().Cast();
foreach (Segment segment in segments)
{
StringBuilder strPipeInfo = new StringBuilder();

using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"C:\REVIT\WriteLines.txt", true))
{
file.WriteLine(Convert.ToString(segment.Name));

}
foreach (MEPSize size in segment.GetSizes())
{
using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"C:\REVIT\WriteLines.txt", true))
{
file.WriteLine(Convert.ToString(Math.Round(size.NominalDiameter * 25.4 * 12, 0)) + " " + Convert.ToString(Math.Round(size.InnerDiameter * 25.4 * 12, 0)) + " " + Convert.ToString(Math.Round(size.OuterDiameter * 25.4 * 12, 0)));

}
}
}
}

Dear Drew,

Thank you very much for sharing this!

It looks perfect: succinct, effective, easy.

I will happily promote this little sample snippet to a main blog post to ensure that it is easy to find.

Cheers, Jeremy.

Dear Drew,

I just noticed that a code snippet very similar to yours is also provided in the Revit API help file RevitAPI.chm description of the Segment class.

Cheers, Jeremy.

Dear Drew,

I added the code as a new external command to The Building Coder samples:

http://thebuildingcoder.typepad.com/blog/2015/02/list-pipe-sizes-and-more-obsolete-api-usage-removal.html

Thank you!

Cheers, Jeremy.

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment

Your Information

(Name and email address are required. Email address will not be displayed with the comment.)

Jeremy Tammik

AboutTopicsIndexSource