DevLab and Room Separation

Today is DevLab with almost fifty participants, so we are in several separate rooms.
I never left the Revit room, and am busy enough with that.
Talk about room separation.

Here are one or two little items that cropped up today, contributed by Eric Boehlke of

truevis.com
.
The first is actually a question on the creation of room separation lines that I already replied to in response to a

comment
from
Ammar on

creating a mass
:

Creating a Room Separation Line

Question: It seems that we have no access to create room separation lines?

Answer: Please check out the NewRoomBoundaryLines, NewSpaceBoundaryLines, NewSpaces and other related methods.

Eric ran into the same issue, and the answer I provided to Ammar does not show up in his Google search attempt, so here it is now, promoted to a main blog post status.

Here is Eric’s code snippet to generate a 10 by 8 room by first creating a rectangular sequence of four room separation lines using the NewRoomBoundaryLines method on a given level:


/// <summary>
/// Create a room on a given level.
/// </summary>
void CreateRoom(
  Document doc,
  Level level )
{
  Application app = doc.Application;
 
  Autodesk.Revit.Creation.Application
    appCreation = app.Create;
 
  Autodesk.Revit.Creation.Document
    docCreation = doc.Create;
 
  XYZ pt1 = new XYZ( 0, -5, 0 );
  XYZ pt2 = new XYZ( 0, 5, 0 );
  XYZ pt3 = new XYZ( 8, 5, 0 );
  XYZ pt4 = new XYZ( 8, -5, 0 );
 
  Line line1 = appCreation.NewLine( pt1, pt2, true );
  Line line2 = appCreation.NewLine( pt2, pt3, true );
  Line line3 = appCreation.NewLine( pt3, pt4, true );
  Line line4 = appCreation.NewLine( pt4, pt1, true );
 
  CurveArray curveArr = new CurveArray();
 
  curveArr.Append( line1 );
  curveArr.Append( line2 );
  curveArr.Append( line3 );
  curveArr.Append( line4 );
 
  docCreation.NewRoomBoundaryLines(
    doc.ActiveView.SketchPlane,
    curveArr, doc.ActiveView );
 
  // Create a new room
 
  UV tagPoint = new UV( 4, 0 );
 
  Room room = docCreation.NewRoom(
    level, tagPoint );
 
  if( null == room )
  {
    throw new Exception(
      "Create a new room failed." );
  }
  room.Number = "42";
  room.Name = "Lobby";
 
  RoomTag tag = docCreation.NewRoomTag(
    room, tagPoint, doc.ActiveView );
}

CopyPathEx and Other Nifty Utilities

Eric also pointed to a list of

great freeware for Revit work
,
from which I immediately installed
PathCopyEx
PathCopyEx.msi.
Many thanks to Eric for his code snippet and helpful pointers!

Now I have to start thinking about getting down to the airport in time for my flight back home to Europe…


Comments

9 responses to “DevLab and Room Separation”

  1. Hi Jeremy,
    another Q -not as silly like last one-
    I couldn’t find any clue on how to start an in-place mass family,

    however if i start it manually then i can create forms in it through API

    a silly tip i suggest to new API coders such as myself:
    use the Visual Studio object viewer to search for an object -i liked it more than searching in SDK html or pdf-
    helps when the autodesk tutorials doesn’t tell what namespaces to use, or searching for bit more documentation on certain object

  2. another related one -sorry-
    other than MassInstanceUtils class
    is there any way to play with in-place masses?
    I want to gain access to forms inside the in- place mass
    thanks

  3. Hi,
    I was wondering if I can find some useful documentation on GetLineStyleIds method. I am trying to fill a C# plugin ComboBox with available line styles within the active Revit document, but I don’t even know how to initialize the CurveElement type to use the GetLineStyleIds method. And I haven’t found a single example on how to do this! Maybe I am completely on a wrong track starting from:
    CurveElement curveElem = new CurveElement(); //Error
    I am a newbie, please help!
    Thanks

  4. Dear Ed,
    Yes, in the Revit API the class constructors are rarely used.
    If you are a newbie, the very first thing to do is to install RevitLookup.
    Then use that to explore the database contents.
    Maybe you can retrieve the line styles using a filtered element collector?
    Cheers, Jeremy.

  5. Dear Ammar,
    Thank you for the tip on using the Visual Studio object browser, it is definitely a powerful tool.
    Yes, sorry to say, there is no API access at all to in-place families.
    The workaround is to create a standard family instead, and insert a single instance of it.
    Cheers, Jeremy.

  6. Hi,
    i am trying to use this code in Revit 2014, but Revit crashes without any errors.
    What can it be?
    Thanks

  7. How i know which room unTag? (use api)

  8. Dear Dannisha,
    Sorry, I do not understand your question. Please clarify. Thank you!
    Cheers, Jeremy.

  9. Dear Sergey,
    I have no idea.
    Can you describe in more detail what happens?
    As a first step forward, I would suggest stepping through the add-in external command source code in the Visual Studio debugger line by line and seeing what statement is causing the problem.
    Cheers, Jeremy.

Leave a Reply

Discover more from Autodesk Developer Blog

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

Continue reading