I mentioned the main new features of the upcoming Revit 2012 API last week. Many of the improvements were directly driven by requests from developers, and many of the most common wish list items have been addressed. Here are a couple of examples of this:
- Full read and write access to wall and floor layer compound structure and wall reveals.
- Read and write access to wall join functionality.
- Access to the paint material for walls.
- Access to linked file information.
Question: Is it possible in Revit to create a wall style and add or delete layers within the wall style?
If I look at the API functions I cannot find an option to add or delete a material from or to a wall style. Nor do I see any possibility to create a new CompoundStructureLayer (constructor) to add it to a CompoundStructureLayerArray. The CompoundStructureLayerArray function has only functions to add or insert a CompoundStructureLayer to the CompoundStructureLayerArray, but no function to delete or move an array member. Is there another solution to solve this problem?
Answer: In the Revit 2011 API, you cannot create new layers in a wall type's compound layer structure. That, however, has been enhanced in Revit 2012, which will allow you to freely create and manipulate the compound layer structure as you see fit.
I presented a work-around for Revit 2011 in the discussion on system family creation: create the required number of layers manually and save the wall types in the template file. Then, when your application needs a new wall type with a specific number of layers, it can use a suitable one of the manually created predefined wall types by duplicating and modifying that.
As said, the Revit 2012 now does offer this capability.
This is one of the very first new features mentioned in the pre-release API documentation:
The CompoundStructure class has been replaced. The old CompoundStructure class in the API was read-only and supported only the nominal layers list without support for the settings related to vertical regions, sweeps, and reveals. The new CompoundStructure class supports read and modification of all of the structure information include vertical regions, sweeps and reveals.
The CompoundStructure.Layers property has been replaced by CompoundStructure.GetLayers() and CompoundStructure.SetLayers().
The CompoundStructureLayer class has also been replaced for the same reasons as CompoundStructure.
The following table maps properties from the old CompoundStructureLayer to the new version of the class: The property HostObjAttributes.CompoundStructure has been replaced by two methods:
Remember that you must set the CompoundStructure back to the HostObjAttributes instance in order for any change to be stored in the element.
In addition to the information on wall sweeps found in the CompoundStructure class, there is a new API representing a wall sweep or reveal. The WallSweep class is an element that represents either a standalone wall sweep/reveal, or one added by the settings in a given wall's compound structure. Standalone wall sweeps and reveals may be constructed using the static method Create().
CompoundStructure and WallSweeps
Old property New property Notes DeckProfile DeckProfileId Is now an ElementId DeckUsage DeckEmbeddingType Uses a different enum Function Function Uses a different enum Material MaterialId Is now an ElementId Thickness Width Variable N/A Not part of the layer class, use CompoundStructure.VariableLayerIndex instead.
Question: How can I retrieve information such as object id, geometry, parameters, etc. for wall reveals? I know how to obtain this data for wall sweeps, but not reveals. Please advise.
Answer: As indicated by the last paragraph quoted above, the Revit 2012 API provides full access to wall sweeps and reveals. It provides the WallSweep and WallSweepInfo classes which cover the properties of these elements.
There are two kinds of sweeps and reveals: those defined in the wall structure itself, and those placed externally and attached to the wall. In the former case, the WallSweepInfo can be obtained directly from the CompoundStructure. In the latter, the WallSweep element subtype can be found, and related to the wall by querying its GetHostIds property.
Question: How can I programmatically access the "Disallow Join" option for Wall objects?
Answer: The ability to disallow wall joins has been requested in the past by other partners, and the Revit 2012 API now provides it:
The new methods
provide access to the setting for whether or not joining is allowed at a particular end of the wall. If joins exist at the end of a wall and joins are disallowed, the walls will become disjoint. If joins are disallowed for the end of the wall, and then the setting is toggled to allow the joins, the wall will automatically join to its neighbours if there are any.
Allow and disallow wall end joins
Question: I can use the Revit Paint tool to define the material of part of a wall surface. How would I retrieve the paint material information including its geometry?
Answer: The Revit 2011 API does not provide access to the split faces on a wall or their paint information.
The Revit 2012 API, however, provides the ability to get the regions of each face of solids, e.g. walls, and each region will provide material information too. The Revit 2012 API help file RevitAPI.chm states the following:
This property and method provide information about the faces created by the Split Face command. HasRegions returns a Boolean value indicating if the face has any Split Face regions. GetRegions returns a list of faces. As the material of these faces can be independently modified through the UI with the Paint tool, the material of each face can be found from its MaterialElementId property.
Face.HasRegions & Face.GetRegions()
With this new API in Revit 2012, you should be able to retrieve the different paint materials on split surfaces of a wall.
Question: I would like to use the Link Revit file functionality from the API, but I cannot find any solution on how to execute such an operation from the API.
I would also be interested in moving such a linked document. For this I need to know exactly where it is, but the Location property value is not of LocationPoint type.
Answer: One focus of the Revit 2012 API is the ability to obtain the information about linked files.
It provides the following new features related to Linked Models:
The API can now tell what elements in Revit are references to external files, and can make some modifications to where Revit loads external files from.
An Element which contains an ExternalFileReference is an element which refers to some external file (ie. a file other than the main .rvt file of the project.) Two new Element methods, IsExternalFileReference() and GetExternalFileReference(), let you get the ExternalFileReference for a given Element.
ExternalFileReference contains methods for getting the path of the external file, the type of the external file, and whether the file was loaded, unloaded, not found, etc. the last time the main .rvt file was opened.
The classes RevitLinkType and CADLinkType can have IsExternalFileReference() return true. RevitLinkTypes refer to Revit files linked into another Revit project. CADLinkTypes refer to DWG files. Note that CADLinkTypes can also refer to DWG imports, which are not external file references, as imports are brought completely into Revit. A property IsImport exists to let users distinguish between these two types.
Additionally, the element which contains the location of the keynote file is an external file reference, although it has not been exposed as a separate class.
There is also a class ExternalFileUtils, which provides a method for getting all Elements in a document which are references to external files.
Additionally, the classes ModelPath and ModelPathUtils have been exposed. ModelPaths can store paths to a location on disk, a network drive, or a Revit Server location. ModelPathUtils provides methods for converting between modelPath and String.
Finally, the class TransmissionData allows users to examine the external file data in a closed Revit document, and to modify path and load-state information for that data. Two methods, ReadTransmissionData, and WriteTransmissionData, are provided. With WriteTransmissionData, users can change the path from which to load a given link, and can change links from loaded to unloaded and vice versa. (WriteTransmissionData cannot be used to add links to or remove links from a document, however.)
Newly exposed classes:
External File References (Linked Files)
As you saw in the Revit 2012 API overview, these items form just a small subset of all the issues addressed, so we can continue looking forward to ever greater possibilities and more powerful applications using the Revit API.
hi Jeremy,
great to have (dis)allow wall end joins feature in 2012 API, but what about join 2 parallel adjacent walls?
user can manually join it but looks like not available yet in API.
hope don't have to wait till 2013 API.
cheers.
Ning
Posted by: ning zhou | March 30, 2011 at 11:32
Dear Jeremy Sir,
Can i display all Families from revit in treeView of Windows forms as such in Project Browser window in Revit?
Regards,
Nitin
Posted by: Account Deleted | March 31, 2011 at 05:31
Dear Ning,
I asked the development team, and there is not even a wish for this registered yet, so I submitted one for you. You are an ADN member, aren't you? In future, it would be better to do this through a DevHelp Online request, actually. If you like, you can still do so, and I will hook up the wish list item I created with your case.
Cheers, Jeremy.
Posted by: Jeremy Tammik | March 31, 2011 at 06:27
Dear Nitin,
Yes, of course you can do that. You can determine all families in the document and set up a tree view using the functionality provided by Windows and the .NET framework. You could classify the individual families by their category, for instance. I think that would more or less match what the Revit project browser does.
For an example of determining all families and the symbols defined in them, you can look at
http://thebuildingcoder.typepad.com/blog/2010/12/xml-family-usage-report.html
Cheers, Jeremy.
Posted by: Jeremy Tammik | March 31, 2011 at 10:15
Thanks for the support.
I have another question, now can i drag and drop selected family symbol from TreeView of windows form to the Revit?.
Regards,
Nitin
Posted by: Account Deleted | March 31, 2011 at 11:26
thanks Jeremy, i just submitted ADN support request, ID is 1268147, thanks again. Ning
Posted by: ning zhou | March 31, 2011 at 11:32
Dear Ning,
Thank you for submitting the DevHelp Online request for this!
That makes it much easier to follow up and keep track of the issue in our knowledge base.
Cheers, Jeremy.
Posted by: Jeremy Tammik | March 31, 2011 at 11:54
Dear Nitin,
It is a pleasure!
The Revit API does not provide any dedicated support for drag and drop. You may be able to simulate whatever user interactions Revit does support, or make use of iDrop. As always, first explore what the Revit user interface has to offer, and then ask yourself whether you can reproduce your required behaviour programmatically.
Cheers, Jeremy.
Posted by: Jeremy Tammik | March 31, 2011 at 11:58
Dear Jeremy Sir,
Now i have populated all family instances in TreeView from xml file, now i need to display selected family instance image in same windows form.
Please help.
Regards,
Nitin
Posted by: Account Deleted | April 01, 2011 at 08:30
Dear Nitin,
Congratulations on your progress. Look at
http://thebuildingcoder.typepad.com/blog/2010/05/get-type-id-and-preview-image.html
Cheers, Jeremy.
Posted by: Jeremy Tammik | April 01, 2011 at 12:01
Dear Jeremy sir,
May i know how the families have been populated in project browser in Revit, i mean on what basis they have populated because i m getting families in tree view which are differ from the those which are in Revit.
Thanks & Regards,
Nitin
Posted by: Account Deleted | April 08, 2011 at 01:01
Dear sir,
May i know what is iDrop?
Regards,
Nitin
Posted by: Account Deleted | April 08, 2011 at 01:21
Dear Nitin,
Look for i-drop in the Autodesk Developer Center:
http://usa.autodesk.com/adsk/servlet/index?siteID=123112&id=1862830
Cheers, Jeremy.
Posted by: Jeremy Tammik | April 08, 2011 at 01:27
Dear Nitin,
Yes, I can imagine that the project browser displays families in a way that is supposed to be more intuitive for end users.
Cheers, Jeremy.
Posted by: Jeremy Tammik | April 18, 2011 at 09:21
Dear Jeremy sir,
Can i use "iDrop" technology with .rfa files.
Regards,
Nitin
Posted by: Account Deleted | April 19, 2011 at 03:36
Dear Nitin,
The basic information on i-drop is available from the Autodesk Developer Center:
http://usa.autodesk.com/adsk/servlet/index?siteID=123112&id=1862830
To find information on using it with Revit family files, you can simply google for "i-drop revit family". That brings up a number of relevant hits for me.
Cheers, Jeremy.
Posted by: Jeremy Tammik | April 20, 2011 at 03:10
Dear Jeremy Sir,
How can i read All Points(Elements or Geometry) present in current documents with out seleting them.
Thanks & Regards
NAmit Jain
Posted by: Account Deleted | May 16, 2011 at 01:35
Dear Jeremy Sir,
How can i read All Points(Elements or Geometry) present in current documents with out seleting them in Revit MEP 2012 MEP
Thanks & Regards
Namit Jain
Posted by: Account Deleted | May 16, 2011 at 01:38
Dear Namit Jain,
There are a number of ways to proceed. One is to read the geometry of all elements and collect the points from that. For greater efficiency, you may want to filter the points you find and only keep unique instances. This is demonstrated by various blog posts on geometry:
http://thebuildingcoder.typepad.com/blog/geometry
For instance, you can use the approach illustrated by the XyzEqualityComparer helper class and the way I make use of it in the GetVertices method in
http://thebuildingcoder.typepad.com/blog/2009/05/nested-instance-geometry.html
Cheers, Jeremy.
Posted by: Jeremy Tammik | May 18, 2011 at 05:11
Hi Jeremy,
1) Thanks for your fantastic work on the Revit API!
2) Given a collection of WallSweep objects, how can one obtain its (XYZ) Location?
eg.
Dim sweepSet As Autodesk.Revit.DB.FilteredElementCollector = New Autodesk.Revit.DB.FilteredElementCollector(aRevDoc)
Dim sweepCol As ICollection = sweepSet.OfClass(GetType(DB.WallSweep)).ToElements()
For Each aSweep As WallSweep In sweepCol
Dim aLocation As LocationPoint = TryCast(aSweep.Location, LocationPoint)
Dim aLocationCurve As LocationCurve = TryCast(aSweep.Location, LocationCurve)
Next
aLocation and aLocationCurve always are null.
The .WallSweepInfo has a few clues on its location, such as .Distance .DistanceMeasuredFrom and even .WallOffset.
Do I need to navigate up to the wall on which it is hosted?
Thanks again!
Konrad.
Posted by: Kon Samulis | February 14, 2012 at 20:06
Dear Konrad,
1. Thank you very much for your appreciation!
2a. How do you create a model with these WallSweep objects to test?
2b. Navigating up to the hosting wall sounds like a very good idea.
2c. Have you used RevitLookup to explore your model, the wall sweeps, and their hosts? You can navigate and look interactively at all their relationships, geometry and location information yourself.
Cheers, Jeremy.
Posted by: Jeremy Tammik | February 15, 2012 at 07:07
Dear Jeremy,
I have some problem with updating revit linked files path.
My plugin works fine with clasic files which are closed but
it don't work with a central file or the local associated files.
My question is, is there a special way to change links path for
a central file?
Thanks
V.
Posted by: Valentin | February 21, 2012 at 05:46
Dear Valentin,
The same steps that work for a file without worksets should work for files with worksets, as long as the applicable worksets are editable.
Cheers, Jeremy.
Posted by: Jeremy Tammik | February 23, 2012 at 07:26
The Autodesk Revit Architecture program lets architects and designers brainstorm and design their projects directly on their computer. If you wish to change something about the design, the program lets you issue revisions that are posted in the "Sheet Issues/Revisions" dialog. Once issued, a revision cannot be "deleted," but it can be merged with another revision. Once a revision is merged, it no longer appears in the "Sheet Issues/Revisions" dialog and all of its information is lost, meaning the difference between deleting a revision and merging a revision is only nominal.
Posted by: Janser | October 19, 2012 at 18:06
I was trying to find the difference between the wall centerline and the core centerline of a wall, so I created a IList of the compoundstructure then did a bunch of work using the function of the layers to figure out where the core was and got a result. However if there are 2 layers vertically stacked within the wall then it all goes to pot... is there a way to treat the 2 vertically stacked layer as 1? or in fact another way to find the difference between the wall and core centerline location?
Posted by: DREW JARVIS | April 09, 2014 at 12:05
Dear Drew,
Thank you for submitting this question as an ADN case 09454026 [Finding the Wall v Core Centerline] as well.
I and my colleagues will attend to it as soon as we possibly can.
By the way, the Revit 2015 API includes some enhancements accessing stacked walls and the relationships between their components, so you should definitely take a look at that as soon as you can.
Good luck!
Cheers, Jeremy.
Posted by: Jeremy Tammik | April 10, 2014 at 06:43