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.
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!
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?)
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!
I created now 3D-Solids between attributes ABSHMIN and ABSHMAX, I hope that is what you are looking for.
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:
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)
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 🙂