DOWNLOADdownload v1.13 - beta - code cleaned. all modules were exported en reimported to create a clean version.download v1.12 - centralized constants for aex-columns download v1.11 - first public release MANUAL AEX![]() when you [ALT-F8 -> SELECT AEX.Run -> RUN] the AEX-application, you'll see the above image selecting [length, area and volume] will export these properties of the AutoCAD entities in the active drawing to Excel. selecting [attributes of blocks] will export all the attribute data to excel. selecting [export object parameters] gives you the possibility to export or import whole objects. when importing from excel, [length, area and volume] and [attributes of blocks] are disabled. REMARKS: - AEX only works on THAWN layers. - this application DOESN'T create a new sheet for each export action or a new drawing for an import action. this means data in the AEX-sheer will be overwritten and extra entities are added in the current drawing. - no layers are created when importing data. You must create them or write a function to import new layers. PROGRAM STRUCTURE![]() the (main) form is called [frmAEX]. You'll also find several modules: [A2E_Attributes] -> attribute extraction [A2E_Entities] -> length-and-stuff axtraction [A2E_Objects] -> object properties extraction [Acad_Functions] -> AutoCAD functions (e.g. checking layers) [AEX] -> runs the macro [E2A_Objects] -> object properties creation [Excel_Functions] -> excel functions (e.g. checking sheets, exporting data) [Messages] -> messages to the user and the bonus: [Sort_and_sum] -> sort and sum excel sheets (not implemented yet. use the excel version) the different modules are created to keep the project structure clear. All functions that do something in Excel should be in [Excel_Functions]; all functions that create objects fron excel in autocad should be in [E2A_Objects]. Simple. EXPORTING OBJECTS[A2E_Objects|Evaluate_Object()]if an object may be exported this function is called. the [Select Case] structure determines the type of object and calls [Excel_Functions|Export_Object] to export the data to excel. the minimum parameters for calling [Excel_Functions|Export_Object] are ["OBJECT NAME", Layer, Color, Handle]. extra parameters can be added freely. EXAMPLE: [Layer], [Color] and [Handle] are set earlier in the function.
Case "AcDbCircle"
XYZPoint = ThisDrawing.ModelSpace.Item(ThisObject).Center
Radius = ThisDrawing.ModelSpace.Item(ThisObject).Radius
Result = Export_Object("Circle", Layer, Color, Handle, XYZPoint, Radius)
IMPORTING OBJECTS[Excel_Functions|Import_Objects]this function iterates the [AEX]-sheet until a row with the an empty first column is found (end of data is assumed). again a [Select Case] structure is used to determine the type of data. [GetParameters()] gets the data on that row an empty cel is found (end of data is assumed). EXAMPLE:
Case "circle"
Result = Create_Circle(GetParameters(AEXRow))
the function [E2A_Objects|Create_Circle] will create the circle from the passed parameters. EXAMPLE:
Function Create_Circle(Parameters)
Dim circleObj As AcadCircle
Dim centerPoint(0 To 2) As Double
Dim radius As Double
AddProgress ("- Importing AEXobject Circle")
On Error GoTo ErrorHandler
' Define the circle
Error_text = "XYZ error"
centerPoint(0) = Parameters(colFirst + 1)
centerPoint(1) = Parameters(colFirst + 2)
centerPoint(2) = Parameters(colFirst + 3)
Error_text = "Radius error"
radius = Parameters(colFirst + 4)
' Create the Circle object in model space
Set circleObj = ThisDrawing.ModelSpace.AddCircle(centerPoint, radius)
' en zet de laatste parameters
Error_text = "Layer error"
circleObj.Layer = Parameters(colAEXLayer)
Error_text = "Color error"
circleObj.Color = Parameters(colAEXColor)
Error_text = "Succes"
ErrorHandler:
Create_Circle = Error_text
End Function
please notice the following things: [colFirst] variable in [centerPoint(0) = Parameters(colFirst + 1)]. [colFirst] is the LAST DEFAULT column, so [colFirst + 1] is the first column with object specific data. [On Error GoTo ErrorHandler] makes sure the application keeps running when an error occures. if an error occures after [Error_text] is set to ["This error"], ["This error"] is the value that [Create_Circle = Error_text] will return. this helps to determine the nature of the erroneous data. [AddProgress ("- Importing AEXobject Circle")] provides the user with the progress of AEX. !!! Calling [AddProgress] once and [Error_text =] four times each time a circle is created will slow down the application. it's possible to leave them out, but this gives the user no information at all. !!! if errorhandling is not udes, still make sure the function returns AT LEAST SOME data. and since the result of the function is put in the column [AEX|ERROR] and since, as mentioned before, the data is read until the first empty cell... [Set circleObj = ThisDrawing.ModelSpace.AddCircle(centerPoint, radius)] read the on-line autocad manual on how to create other objects. if you're clueless: put the cursor on [AddCircle] and [F1] will give you a good startingpoint. CONCLUSIONfrom here you're on your own. for more information, use the on-line documentation and internet for more examples.EXTRA INFORMATIONwhen AEX was created is was faster to push data to excel from autocad than to pull the same data from autocad in excel. that's why the whole application was written in autocad.for more VBA applications in AutoCAD and or Excel: mail <beintema@dds.nl> this document was created on September 6th 2001 and reflects the status of AEX version 1.11 |