Thank you so much for the help I was desperate to see a replay and sorry for not being specific earlier.I've length and elevation of a ground profile for a path along which a trench has to dig with a certain depth and I need to create the longitudinal profile for the at ground level and bottom of the trench (or consider ill give the level of trench bottom also). And in the bottom of the profile a table having the values length, Ground level, trench bottom level and depth of cutting (Ground level - trench bottom level). And a datum value (if calculated automatically or I can provide it). And sorry sir I'm bad at explaining so I've drawn one example.Something similar to that.Thanks in advance.
These are free to download AutoCAD Blocks. These files has been saved in AutoCAD 2006. Our drafting details will be useful in any DWG compatible CAD software package. Have you tried BricsCAD, Chief Architect, DesignCAD 3D Max, DraftSight, LibreCAD, Microstation PowerDraft, nanoCAD,ProgeCAD, Sketchup, Solidworks, TurboCAD, Vectorworks and ZWCAD?
Into the Database - Part 1
Hold onto your hat because we're going to dive straight in here.
Fire up AutoCad and draw a line anywhere on the screen.
Now type this then press Enter:
Fire up AutoCad and draw a line anywhere on the screen.
Now type this then press Enter:
Lisp should return something like this:
This is the Entity Name of the Line that you have just drawn.
Now type 'Erase' then !a and press Enter twice.
The line should disappear. Type 'OOPS' to bring it back.
You have just modified the AutoCAD Database.
Now type 'Erase' then !a and press Enter twice.
The line should disappear. Type 'OOPS' to bring it back.
You have just modified the AutoCAD Database.
Now type this :
This will retrieve the Entity Data. It should look something like this:
Now type this line:
Lisp should return:
Before you type the next few lines, make sure that your snap is turned off.
A circle should be drawn at the end of the line.
This exercise was just to show you the ability of AutoLisp to go behind your drawing, into the database, and manage graphic and non-graphic information. This tutorial will show you how entities are stored and referenced in the database.
It will show you how AutoLisp reveals data about entities and how they can be modified and manipulated. Say au revoir to your wife and kid's and let's visit the AutoCad Database. (Star Trek theme music now starts…)
It will show you how AutoLisp reveals data about entities and how they can be modified and manipulated. Say au revoir to your wife and kid's and let's visit the AutoCad Database. (Star Trek theme music now starts…)
Into the Database - Part 2
When you first start to delve into the AutoCAD database it is, I admit, quite daunting. But, although entity access and manipulation is fairly complex, it can be divided into component parts that make it much easier to understand.
Let's have a look at an AutoLisp routine that can be used, as a sort of template
which you can apply to numerous, similar applications. Have a close look at this coding :
Let's have a look at an AutoLisp routine that can be used, as a sort of template
which you can apply to numerous, similar applications. Have a close look at this coding :
This routine allows you to select any number of objects and change them to a different layer. The target layer is choosen by simply pointing to an object on the desired layer. (To test this routine, you will need to create a drawing with objects on different layers.) Let's have a look line by line :
Defines the function and declares all variables as local.
Prompts the user.
Allows the user to select the objects to be changed. The selection set is assigned to variable 'a1'.
Prompts the user to select the Target Layer.
This is a special type of selection statement that only allows you to
select one entity.
select one entity.
Counts the number of entities in the selection set 'a1' and stores this number in variable 'n'.
Sets the loop control variable 'index' to zero.
This statement retrieves the entity list from 'a2' and assigns it to 'b2'.
This looks for the code 8 in the entity list 'a2', and then assigns the sub list to 'd2'.
This begins the loop that pages through the selection set.
This gets the entity list and assigns it to 'b1'.
Gets the sublist code 8. (The Layer)
Substitutes the new 'd2' layer for the old 'd1' layer in the entity list 'a1', and assigns it to the new entity list 'b3'.
Updates the new entity list in the database.
Increases the 'index' variable by 1, priming it for the next loop.
Closes the repeat loop.
Finish cleanly.
Closes the function.
Clean Loading.
Listed below is another routine that allows you to globally change the height of text without affecting other entities. As you will see, the only difference is, is that we have added a conditional filter to the routine.
Well I bet your brain hurts after that lot!!!
On the text page we'll have a quick look at Tables.
On the text page we'll have a quick look at Tables.
Into the Database - Part 3
The AutoCad Database does not only consist of entities but also includes several other sections, such as the Tables Section.
Tables store information about entities that are maintained globally within the drawing. For example, when you insert a block into a drawing, how does AutoCAD know what the block looks like? The definition of a block is stored in the Block Table. What happens, for example, if you need to create a layer? You have to know if the layer already exist because if you try to create a layer that already exists your program will crash. Therefore, you would search the Layers Table first to see if the layer exists.
Tables store information about entities that are maintained globally within the drawing. For example, when you insert a block into a drawing, how does AutoCAD know what the block looks like? The definition of a block is stored in the Block Table. What happens, for example, if you need to create a layer? You have to know if the layer already exist because if you try to create a layer that already exists your program will crash. Therefore, you would search the Layers Table first to see if the layer exists.
There are nine (9) Tables that you can access :
A Table is split into 2 parts: The 'names' of the entries in the Table and the 'details' of each entry. For example, in the Layers Table, the name of the entries would be the names of the layers that exist. The details of an individual layer would be colour, linetype, on, off, frozen, thawed, locked, unlocked or current.
To access a Table we would use the (tblsearch) function. Let's have a look at an example :
Assume that you want to know whether a layer called STEEL exists in your drawing. First create the layer STEEL then type the following :
The entity list of the layer STEEL should be returned :
The first part of the entity list is '0', indicating Associative 0.
In this case it's an entry in the 'LAYER' Table.
Associative 2 indicates the name of the layer. STEEL in our case.
Associative 70 is the state of the entity. 1 is Frozen, 2 is Frozen on new paper space view ports and 4 is locked. These numbers are added to 64. In this case the layer is neither frozen nor locked.
Associative 62 is the colour of the layer. Ours is white which is colour number 7. If the colour number is a negative number then the layer is off.
Associative 6 is the linetype of the layer, in this case, 'CONTINUOUS'.
In this case it's an entry in the 'LAYER' Table.
Associative 2 indicates the name of the layer. STEEL in our case.
Associative 70 is the state of the entity. 1 is Frozen, 2 is Frozen on new paper space view ports and 4 is locked. These numbers are added to 64. In this case the layer is neither frozen nor locked.
Associative 62 is the colour of the layer. Ours is white which is colour number 7. If the colour number is a negative number then the layer is off.
Associative 6 is the linetype of the layer, in this case, 'CONTINUOUS'.
If the (tblsearch) had not found the layer then it would have returned 'nil' and you would know that the layer did not exist.
Sometimes you don't know the name of a layer or a block but you need a list of them. This is when the (tblnext) function comes into play.
Let's assume that 4 layers exist in your drawing. The layer names are MECH, STEEL, PIPE and TXT. Enter the following :
AutoLISP should return something like this :
Repeat the same command four additional times. You will get a new entity list for each of the layers. The last time you type the command AutoLISP will return 'nil' because there are no more additional layers.
Let's have a look at this in action. We are going to design a dialogue box that displays a drop down list of all the available layers in a specific drawing. The user can then choose any layer which can then be used within his routine.
The Dialogue Coding looks like this :
Now the AutoLisp Coding :
If you would like the source coding for this AutoLisp Routine then simply Click Here. Cheers and keep well…