Enclosed Region using Room Separator

Enclosed Region using Room Separator

Anonymous
Not applicable
2,005 Views
5 Replies
Message 1 of 6

Enclosed Region using Room Separator

Anonymous
Not applicable

How can I programmatically create an enclosed space using Room Separators and assign Room object to it. Can somebody provide a sample code to work with Room Separator.

 

 

0 Likes
Accepted solutions (1)
2,006 Views
5 Replies
Replies (5)
Message 2 of 6

atiefenbach
Advocate
Advocate
Accepted solution

This should get you going:

public void CreateRoomAndSeperators()
{
	Document doc = this.ActiveUIDocument.Document;
	View activeView = doc.ActiveView; //You should make sure you're in a Plan View
	
	XYZ pt1 = new XYZ(0, 0, 0);
	XYZ pt2 = new XYZ(0, 10, 0);
	XYZ pt3 = new XYZ(10, 10, 0);
	XYZ pt4 = new XYZ(10, 0, 0);
	
	UV pt5 = new UV(5, 5);
	
	CurveArray curveArray = new CurveArray();
	curveArray.Append(Line.CreateBound(pt1, pt2));
	curveArray.Append(Line.CreateBound(pt2, pt3));
	curveArray.Append(Line.CreateBound(pt3, pt4));
	curveArray.Append(Line.CreateBound(pt4, pt1));
	
	using (Transaction trans = new Transaction(doc))
	{
		trans.Start("Create Room and Boundaries");
		ModelCurveArray lines = doc.Create.NewRoomBoundaryLines(activeView.SketchPlane, curveArray, activeView);
		Room room = doc.Create.NewRoom(activeView.GenLevel, pt5);
		//now modify the "room" Element's Name, Number, etc.
		trans.Commit();
	}
}
Anthony Tiefenbach
BIM Manager
HuntonBrady Architects
Message 3 of 6

JimJia
Alumni
Alumni
Yes, NewRoomBoundaryLines() is the answer!

Thanks Anthony's code!

Jim Jia
Autodesk Forge Evangelist
https://forge.autodesk.com
Developer Technical Services
Autodesk Developer Network
Email: Jim.Jia@autodesk.com
Message 4 of 6

MiguelGT17
Advocate
Advocate

Some how the code doesnt work if I set the current view as a 3D view. Indeed, the following issue pops up:

MiguelGT17_0-1674145962203.png

 

0 Likes
Message 5 of 6

Tabeer_Tariq
Community Visitor
Community Visitor

Can this be done using dynamo only?

0 Likes
Message 6 of 6

AnthonyTiefenbach
Participant
Participant

I’m sure it’s possible, but you’d probably get a better answer in a Dynamo forum.

0 Likes