How to create a room and tag it

An AUGI user asked

“Is there a way to get the UV point from a user clicking the floor plan view during an active API session?

My goal is provide the user with a list of rooms to place and have them select a room from the list in form, click a point on the floor plan view and create the room via the API.”

Here is a macro to create a room with a room tag

public void CreateRoom()
    Document doc = this.ActiveUIDocument.Document;
    UIDocument uidoc = this.ActiveUIDocument;

    // Get the level of the plan view
    ViewPlan view = doc.ActiveView as ViewPlan;
    Level level = view.GenLevel; // use GenLevel, not Level

    // Create a UV from a point selected by the user (the Z value is not needed)
    XYZ xyz = uidoc.Selection.PickPoint("Select a point");
    UV uv = new UV(xyz.X, xyz.Y);

    using (Transaction t = new Transaction(doc, "Create Room"))
        Room room = doc.Create.NewRoom(level, uv);
        RoomTag tag = doc.Create.NewRoomTag(room,uv,view);

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s