Announcements

The Autodesk Community Forums has a new look. Read more about what's changed on the Community Announcements board.

Automatic Wall Creation in Revit from Imported CAD Drawings (DGN file)

kevin.anggrek
Enthusiast

Automatic Wall Creation in Revit from Imported CAD Drawings (DGN file)

kevin.anggrek
Enthusiast
Enthusiast

Hi all,

 

First of all, I want to know how to automatically create a wall in Revit from a wall in a DGN drawing. As you may have noticed, the DGN File format is a CAD format of the MicroStation, a CAD software from Bentley. My end goal is to be able to recreate Wall elements in Revit from a 2D CAD drawing (DGN file)

 

I am building the Revit API plugin for this by using the C#. I understand that there are several Wall.Create Method Overloads in Revit API. Each with different input arguments.

Recently, I have been playing around with the Create Method (Document, Curve, ElementId, ElementId, Double, Double, Boolean, Boolean) of the Wall Class. The Curve Class input argument is the baseline of the wall, and if my understanding is correct, it is the Location Line of the wall element.

 

My problem is that, I currently can think of two ways to be able to recreate wall elements in Revit based on the 2D DGN Drawing:

1. I have built a MicroStation API to get the Vertices (Vertex/Edge Points) of wall Shape Elements in MicroStation. However, the Curve Class input argument for the wall creation in Revit API is the baseline/centerline of the wall element. Long story short, I am clueless on how to get the centerline coordinates of an object given the Vertices of the object itself. The following picture explains my question more clearly:

As you can see, I have the black coordinate points (vertices), but how can I use this information to be able to get the red coordinate points, which can be used to create Curve for the Wall Create Method.

I have actually looked for some similar topics online, and it seems like everyone on the web recommends the GIS-related approach or other methods that is very complex such as implementing Voronoi or Delaunay Triangulation Algorithms

 

2. Another method I can think of is to first import the DGN drawing into Revit by using the Import CAD tools already available inside Revit. Even so, how can I transform the drawing lines in a CAD file into Wall elements in Revit? I would still need the centerline of the Walls to be able to use the create method to create walls in Revit. Or is there other methods or tips that I am unaware of?

 

P.S. In my DGN drawing, the walls are not accompanied with any centerline drawings, so it is purely just the wall line drawings like this without any centerlines:

 
 

WallClosed.png

 

 

Thank you!

Reply
4,726 Views
6 Replies
Replies (6)

stever66
Advisor
Advisor

That's an interesting question, mostly because it seems like its a simple question, but I doubt there is a simple answer.

 

When we look at the lines, its obvious where the walls are, but how to get a computer to see what we see?  I can only offer a few hints - I think it would really take a professional programmer a lot of time to really make this work every time.

 

Can you cheat and allow some extra user input?  For example, maybe they select pairs of lines?  Or like in this app, maybe they pick a point between the wall edges:

https://forums.autodesk.com/t5/revit-architecture-forum/any-tool-for-making-walls-from-cad-lines/td-...

 

If you really want this to be automatic, then you will have to look for parallel (or almost parallel since the imported lines may not be perfect) lines.   Also notice that in most cases, an opposite side would be within some distance (maybe 1') of the other wall.  That should probably be adjustable - for example, when you add-in is run, ask the user what the thickest wall dimension is, and then search for lines within that distance. 

 

Also notice that you need to look for more than one line to pair up with one wall edge.  For example, the top wall in your 2nd photo has one top line, and two bottom lines.

 

You could also look for loops, since a lot of walls will surround a room or building.  I'm not sure if there is any special command for finding loops, but revit makes a similar check when you create an extrusion or revolve.

 

I think I would start with:

 

1.  Put all the lines (wall edges) in a list.  If you have all nodes, create lines to use, or just calculate the lines and put them in a list.

2.  Start with the longest one, and work your way toward shorter lines. 

3.  Find the right angle direction from the line, and find any other lines that are almost parallel, and within the default distance.  You may have to actually do this several times for each line. For example start with a point at one end, and work you way 1" at a time down to the other end.  That will make sure you find all the other common edges.

3.  Note you will have to check the distance to each line both at a right angle to the line, and parallel to the line.  At a right angle to make sure its an opposite wall edge, and parallel makes sure its along side the first line.   

4.  As you group the wall edges, put them together in another list, and remove them from the first list.

5.  Best would be to show the user a preview before the walls are created, and give them the chance to add or delete walls that aren't correct.

 

Once you have your walls and start drawing them, I think Revit will connect them.

 

 

RPTHOMAS108
Mentor
Mentor

There probably is another lazy option depending on the type of Wall elements you are needing to create in Revit. If you don't need wall elements with grips you can create direct shapes via extrusions of the loops you have.

 

Also you need to consider when did a wall not have a door and when is a door never full height? i.e. 2D extractions are not going to convert to 3D information.

 

The 'L' on the face of it seems relatively easy to resolve if you consider the closest two points in most cases form the ends or intersection of the wall. So the average of each of the closest two points forms the red dots. If you have a short return then this can become difficult to identify the closest two points. However a short return is adjacent to one long edge whilst a wall end is adjacent to two long edges.

 

The reverse 'J' is harder in that at the 'T' junction the average of the two closest points would occur at the side of the intersecting wall not the centre of it. If you were to find the closest four intersecting points of all intersecting wall lines you could average to find most centre intersection points.

 

In the above we have also not considered variable wall thickness and the alignment of such segments.

 

 

 

 

0 Likes

kevin.anggrek
Enthusiast
Enthusiast

Dear stever66,

 

Thank you for taking an interest to my questions.

 


@stever66 wrote:

That's an interesting question, mostly because it seems like its a simple question, but I doubt there is a simple answer.

 

When we look at the lines, its obvious where the walls are, but how to get a computer to see what we see?  I can only offer a few hints - I think it would really take a professional programmer a lot of time to really make this work every time.

 


Yes sir, I have the same thoughts, it is like trying to replace our eyeballs, and I know it would not be easy.


@stever66 wrote:

Can you cheat and allow some extra user input?  For example, maybe they select pairs of lines?  Or like in this app, maybe they pick a point between the wall edges:

https://forums.autodesk.com/t5/revit-architecture-forum/any-tool-for-making-walls-from-cad-lines/td-...


I am striving for an automated process sir, because if there is a lot of walls, it will be tedious for the user to repeat the process for each walls.

 


@stever66 wrote:

If you really want this to be automatic, then you will have to look for parallel (or almost parallel since the imported lines may not be perfect) lines.   Also notice that in most cases, an opposite side would be within some distance (maybe 1') of the other wall.  That should probably be adjustable - for example, when you add-in is run, ask the user what the thickest wall dimension is, and then search for lines within that distance. 

 

Also notice that you need to look for more than one line to pair up with one wall edge.  For example, the top wall in your 2nd photo has one top line, and two bottom lines.

 

You could also look for loops, since a lot of walls will surround a room or building.  I'm not sure if there is any special command for finding loops, but revit makes a similar check when you create an extrusion or revolve.

 

I think I would start with:

 

1.  Put all the lines (wall edges) in a list.  If you have all nodes, create lines to use, or just calculate the lines and put them in a list.

2.  Start with the longest one, and work your way toward shorter lines. 

3.  Find the right angle direction from the line, and find any other lines that are almost parallel, and within the default distance.  You may have to actually do this several times for each line. For example start with a point at one end, and work you way 1" at a time down to the other end.  That will make sure you find all the other common edges.

3.  Note you will have to check the distance to each line both at a right angle to the line, and parallel to the line.  At a right angle to make sure its an opposite wall edge, and parallel makes sure its along side the first line.   

4.  As you group the wall edges, put them together in another list, and remove them from the first list.

5.  Best would be to show the user a preview before the walls are created, and give them the chance to add or delete walls that aren't correct.

 

Once you have your walls and start drawing them, I think Revit will connect them.


I must apologize sir, I am trying to understand the step-by-step that you provided here, but I am at lost trying to digest and visualize the step-by-step procedure that you provided here. Can you give me a small case example in demonstrating your step-by-step procedure to help me understand properly?

 

Also, i actually find the following youtube video: https://www.youtube.com/watch?v=Vvccb7IG9KA

In that video, the API can create 3D walls automatically from a DWG drawing which is similar to my issue. I am wondering whether there is an extrusion method in Revit API from 2D wall drawings to be extruded automatically as 3D walls in Revit? Or do you think this video also demonstrates the wall creation using the Wall.Create Method?

0 Likes

kevin.anggrek
Enthusiast
Enthusiast

Thank you sir for the reply,

 


@RPTHOMAS108 wrote:

There probably is another lazy option depending on the type of Wall elements you are needing to create in Revit. If you don't need wall elements with grips you can create direct shapes via extrusions of the loops you have.


When you mention walls with grips, does that mean the joins of the wall?. And, when you mention about creating direct shapes from extrusion of the loops, does it mean the built-in Revit tool of this: https://knowledge.autodesk.com/support/revit-products/learn-explore/caas/CloudHelp/cloudhelp/2019/EN...? Or do you mean creating extrusions automatically using the API? if this is the case, do you mind to show me how can the API achieve this purpose?

 


@RPTHOMAS108 wrote:

Also you need to consider when did a wall not have a door and when is a door never full height? i.e. 2D extractions are not going to convert to 3D information.

At the current state, all the walls in the DGN drawing I am using is more like a structural drawing with no door definitions at all. Thus, I am not currently considering the existence of the doors for now and just want to be able to focus on creating 3D walls from 2D wall drawings.

 


@RPTHOMAS108 wrote:

The 'L' on the face of it seems relatively easy to resolve if you consider the closest two points in most cases form the ends or intersection of the wall. So the average of each of the closest two points forms the red dots. If you have a short return then this can become difficult to identify the closest two points. However a short return is adjacent to one long edge whilst a wall end is adjacent to two long edges.

 

The reverse 'J' is harder in that at the 'T' junction the average of the two closest points would occur at the side of the intersecting wall not the centre of it. If you were to find the closest four intersecting points of all intersecting wall lines you could average to find most centre intersection points.

 

In the above we have also not considered variable wall thickness and the alignment of such segments.


Thank you for your input sir, I would like to try and rethink the problem again and maybe I could find a pattern that could encompass different polygon shapes.

 

For the wall's thickness, I filter the wall in MicroStation based on its Level (in AutoCAD terms, I filter the elements based on the Layer). Thus, the thickness of the wall will be the same on all edges for each polygon shape under the same Layer. Furthermore, I initially thought that as long as I can get the wall centerlines, I can create a GUI for user to pick the preferred Revit wall type (which contain the information of the wall's thickness) and then use the Wall.Create Method to create a wall based on the baseline curve, and the user's specified wall type and floor level, etc, because by using the wall creation method such as Wall.Create Method (Document, Curve, ElementId, ElementId, Double, Double, Boolean, Boolean), the main challenge for me is the Curve input argument where I would need the wall centerlines. The other input arguments can be covered by user inputs, etc.

0 Likes

RPTHOMAS108
Mentor
Mentor

Direct shapes you can create with the API various ways and many examples exist. You create them using either classes derived from ShapeBuilder or adding a solid from a newly created direct shape object from GeometryCreationUtilities class. There are various functions in that class for creating extrusions from profiles.

 

There are limitations of direct shapes in the sense they can't be manipulated by the user and they can only have parameters assigned by category in the project (not ideal for BIM). That is why you have to decide on the purpose of the Revit model, namely is it going to be used as a background reference or are you expecting users to develop it further after automatic creation (in the data content and/or geometric sense)? If the latter then a model containing direct shapes would not be ideal. You can also create FreeFormElements in the family document in a similar way to direct shape creation but these probably can't be of the Wall category because Wall category is a system family not one you load in.

 

You comments regarding doors I don't completely understand but that may be due to my greater experience with dwgs rather than dgns. Are the door openings not inherently included because the 2D cut is taken just above floor level? If so you will be extruding the door openings up above the level the opening would usually stop at? If the door openings are not included in your 2D output and the wall groups have uniform thickness then your task becomes very easy because a length of a wall is many times greater than it's thickness. Easy therefore to group line endpoints into clusters and consider how straight lines between such form the junction of walls.

 

 

 

 

0 Likes

kevin.anggrek
Enthusiast
Enthusiast

Thank you sir for the inputs and suggestions. Sorry for the delay!

 


@RPTHOMAS108 wrote:

Direct shapes you can create with the API various ways and many examples exist. You create them using either classes derived from ShapeBuilder or adding a solid from a newly created direct shape object from GeometryCreationUtilities class. There are various functions in that class for creating extrusions from profiles.

 

There are limitations of direct shapes in the sense they can't be manipulated by the user and they can only have parameters assigned by category in the project (not ideal for BIM). That is why you have to decide on the purpose of the Revit model, namely is it going to be used as a background reference or are you expecting users to develop it further after automatic creation (in the data content and/or geometric sense)? If the latter then a model containing direct shapes would not be ideal. You can also create FreeFormElements in the family document in a similar way to direct shape creation but these probably can't be of the Wall category because Wall category is a system family not one you load in.

At the current state, the Revit Model should be ideal for BIM. Thus, I am staying away from the DirectShapes. If I were to create a Revit model that is ideal for BIM, the wall elements must be created using the Wall.Create Method right? Or is there any other feasible methods as well? I have also been able to get the wall centerlines to be used as the baseline for the Curve input argument for the Wall.Create Method

0 Likes