Many Issues Resolved

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:

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:

CompoundStructure and WallSweeps

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:

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.

The property HostObjAttributes.CompoundStructure has been replaced by two methods:

  • HostObjAttributes.GetCompoundStructure()
  • HostObjAttributes.SetCompoundStructure()

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().

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:

Allow and disallow wall end joins

The new methods

  • WallUtils.DisallowWallJoinAtEnd()
  • WallUtils.AllowWallJoinAtEnd()
  • WallUtils.IsWallJoinAllowedAtEnd()

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.

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:

Face.HasRegions & Face.GetRegions()

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.

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:

External File References (Linked Files)

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:

  • ExternalFileReference – A non-Element class which contains path and type information for a single external file which a Revit project references. ExternalFileReference also contains information about whether the external file was loaded or unloaded the last time the associated Revit project was opened.
  • ExternalFileUtils – A utility class which allows the user to find all external file references, get the external file reference from an element, or tell whether an element is an external file reference.
  • RevitLinkType – An element representing a Revit file linked into a Revit project.
  • CADLinkType – An element representing a DWG drawing. CADLinkTypes may be links, which maintain a relationship with the file they originally came from, or imports, which do not maintain a relationship. The property IsImport will distinguish between the two kinds.
  • LinkType – The base class of RevitLinkType and CADLinkType.
  • ModelPath – A non-Element class which contains path information for a file (not necessarily a .rvt file.) Paths can be to a location on a local or network drive, or to a Revit Server location.
  • ModelPathUtils – A utility class which provides methods for converting between strings and ModelPaths.
  • TransmissionData – A class which stores information about all of the external file references in a document. The TransmissionData for a Revit project can be read without opening the document.

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.


Comments

26 responses to “Many Issues Resolved”

  1. ning zhou Avatar
    ning zhou

    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

  2. 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

  3. 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.

  4. 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.

  5. 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

  6. ning zhou Avatar
    ning zhou

    thanks Jeremy, i just submitted ADN support request, ID is 1268147, thanks again. Ning

  7. 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.

  8. 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.

  9. 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

  10. Dear Nitin,
    Congratulations on your progress. Look at
    http://thebuildingcoder.typepad.com/blog/2010/05/get-type-id-and-preview-image.html
    Cheers, Jeremy.

  11. 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

  12. Dear sir,
    May i know what is iDrop?
    Regards,
    Nitin

  13. Dear Nitin,
    Look for i-drop in the Autodesk Developer Center:
    http://usa.autodesk.com/adsk/servlet/index?siteID=123112&id=1862830
    Cheers, Jeremy.

  14. 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.

  15. Dear Jeremy sir,
    Can i use “iDrop” technology with .rfa files.
    Regards,
    Nitin

  16. 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.

  17. Dear Jeremy Sir,
    How can i read All Points(Elements or Geometry) present in current documents with out seleting them.
    Thanks & Regards
    NAmit Jain

  18. 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

  19. 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.

  20. 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.

  21. 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.

  22. 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.

  23. 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.

  24. 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.

  25. 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?

  26. 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.

Leave a Reply to Jeremy TammikCancel reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading