AutoCAD - Creating 3D from 2D polygons height attribute?

AutoCAD - Creating 3D from 2D polygons height attribute?

Anonymous
Not applicable
1,852 Views
8 Replies
Message 1 of 9

AutoCAD - Creating 3D from 2D polygons height attribute?

Anonymous
Not applicable
Hi All,
 
Doing a bit of work for my urban planning course. Wanted a 3-d model to do some visuals for an area in the city that is going to be redeveloped. I have a bunch of data that the local authority shared with me that includes polygons and building height data, which I've since exported from MapInfo as a .dxf retaining the attributes for building height. MapInfo had it as a 2d drawing but ideally I'd like to somehow (if it's possible?) instruct AutoCad to turn said polygons into 3D blocks using the attribute data I have. Each polygon has this data but I can't for the life of me figure out how to progress from here.
 
Ultimately I'd like to export it to import into sketchup to do some simple editing (so I've understood I need to avoid making the faces be hatched and instead be regions?). Any help here would be immensely appreciated.
 
Sorry, I'm a bit basic at all of this and am rather muddling my way through! Screenshot attatched.
 
Cheers
 
C
 
 
0 Likes
Accepted solutions (1)
1,853 Views
8 Replies
Replies (8)
Message 2 of 9

Alfred.NESWADBA
Consultant
Consultant

Hi,

 

>> turn said polygons into 3D blocks

Can you upload the drawing so we can look how the objects are defined?

Because what you selected are block-insertions and not polygons.

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2026
------------------------------------------------------------------------------------

(not an Autodesk consultant)
0 Likes
Message 3 of 9

Anonymous
Not applicable
Ah I apologise, my terminology is pretty awful when it comes to this. I'll
upload it when I'm back this evening late.
0 Likes
Message 4 of 9

Anonymous
Not applicable

Hi again,

 

The file is to large to directly attatch so have uploaded it to dropbox: https://www.dropbox.com/s/5bl5i92fp2a4pg4/ModifiedBuidlingHeighData.dxf?dl=0 

 

Thanks for any advice/help.

 

Cheers

 

C

0 Likes
Message 5 of 9

emma.cronin
Participant
Participant

Personally, I would extrude each building up to the desired height. Problem is AutoCAD has no way of knowing that you want said polygon at said height as it's just a shape, if it was made into a named block it *might* have been able to find it and move it to a position in the Z axis, but then you would need to block each building and then probably make a table for the data to be read, probably 20x more work than just extruding each building. Good luck!

 

-Emma Cronin

0 Likes
Message 6 of 9

Anonymous
Not applicable

Ah blast, so there's no way to make AutoCAD take the attribute associated with each block? I only ask because you said AutoCAD doesn't know what height I want it but each shape has an attribute (referred to as RelHMax which is the maximum height of the structure) that is different per each block. You'll see in my screenshot that it says *VARIES* because each block has this attribute where I imported it from a MapInfo file using their universal translator.

 

(If it helps the ToID Attribute is a unique identifier to each block?)

0 Likes
Message 7 of 9

emma.cronin
Participant
Participant

Oh yes! Sorry! Clearly I need to look closer next time! Someone here may be able to produce a macro to interporate the data, I have personally always had issues getting CAD to make sense of data extraction, and gave up due to being impatient!

 

Good luck, hope someone can give you the answer you are looking for!

 

-Emma Cronin

0 Likes
Message 8 of 9

Alfred.NESWADBA
Consultant
Consultant
Accepted solution

Hi,

 

I created now 3D-Solids between attributes ABSHMIN and ABSHMAX, I hope that is what you are looking for.

 

2015-12-16 13-13-41.png

 

The code (VBA, so maybe installing the VBA Enabler for AutoCAD is required) which does this (only done for exact this drawing structure) can be found here:

Spoiler
Spoiler

Option Explicit

Public Sub ExtToAttHeight()
   Dim tEnt As AcadEntity
   For Each tEnt In ThisDrawing.ModelSpace
      If TypeOf tEnt Is AcadBlockReference Then
         Call handleBlockRef(tEnt)
      End If
   Next
End Sub

Private Sub handleBlockRef(ByRef BlRef As AcadBlockReference)
   If BlRef.HasAttributes Then
      Dim tH1 As Double: tH1 = -1
      Dim tH2 As Double: tH2 = -1
      Dim tAtts As Variant: tAtts = BlRef.GetAttributes
      Dim i As Integer
      For i = LBound(tAtts) To UBound(tAtts)
         Select Case UCase(tAtts(i).TagString)
            Case "ABSHMIN": tH1 = Val(tAtts(i).TextString)
            Case "ABSHMAX": tH2 = Val(tAtts(i).TextString)
         End Select
         If (tH1 >= 0) And (tH2 >= 0) Then Exit For
      Next
      If (tH1 >= 0) And (tH2 >= 0) Then
         'ok, there exits valid data
         Dim tBlDef As AcadBlock: Set tBlDef = ThisDrawing.Blocks(BlRef.Name)
         Dim tEnt As AcadEntity
         For Each tEnt In tBlDef
            'search polyline within the blockdefinition
            If (TypeOf tEnt Is AcadPolyline) Or (TypeOf tEnt Is AcadLWPolyline) Then
               Dim tCurves(0) As AcadEntity: Set tCurves(0) = tEnt
               Dim tRegion As AcadRegion: Set tRegion = tBlDef.AddRegion(tCurves)(0)
               'create solid and move it to base-elevation
               Dim tSolid As Acad3DSolid: Set tSolid = tBlDef.AddExtrudedSolid(tRegion, tH2 - tH1, 0#)
               Dim tPnt1(0 To 2) As Double
               Dim tPnt2(0 To 2) As Double: tPnt2(2) = tH1
               Call tSolid.Move(tPnt1, tPnt2)
               tRegion.Delete
               'Exit For
            End If
         Next
      End If
   Else
      'nothing to do
   End If
End Sub


The finished drawing can be downloaded from >>>here<<<.

There is one object extruded down to Z=0 .. because there the attribues are not filled correctly.

 

HTH, - alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2026
------------------------------------------------------------------------------------

(not an Autodesk consultant)
Message 9 of 9

Anonymous
Not applicable

That's fantastic; thank you! I'm nowhere near competent enough to understand the entireity of the code but I'll add the VBA enabler. Oddly enough I was thinking I'd be going from zero to RelHMax but the difference between AbsHMin & Max is RelHMax so it's absolutely perfect!

 

Only issue is that the download link is 404ing at the moment! I'll try doing it myself though 🙂

0 Likes