Dia 1 - CAD College
Dia 1 - CAD College
Dia 1 - CAD College
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
.<br />
Customization<br />
Is The Key To<br />
Successful <strong>CAD</strong> !<br />
By Athier Alwekil<br />
.<br />
,
ED<strong>CAD</strong>® 1.0 is the first version of costom Dev. Tool tailor-made<br />
for SolarTech International B.V<br />
and the Graduation assignment as part of the<br />
HBO – Trajectory ACE System Manager at the TEC / <strong>CAD</strong><br />
<strong>College</strong> in Nijmegen.<br />
Supervised by Dhr . R. Boeklagen<br />
With thanks and appreciation to<br />
mevr. Gea van den boer from Gemeente Nijkerk<br />
Mevr. Leonie Bergsma from <strong>CAD</strong> <strong>College</strong> in Nijmegen.<br />
And a special thanks to .R. Boeklagen<br />
16/12/2010 ED<strong>CAD</strong>1.0 HBO-Traject 2010 2
. About Me:<br />
I have been studied for almost 3 years at University of Technology department of Computer and<br />
Control Systems.<br />
For personal reasons I had to leave Iraq to Netherland.<br />
Then unfortunately several years ago I couldn’t finish my studying.<br />
During working in different jobs I was keep trying to use innovative methods to complete the<br />
work in the best way.<br />
The question was always about my education level and finally I got the opportunity to achieve<br />
My goals to continue my studies<br />
My studying started with:<br />
Auto <strong>CAD</strong> 2D Gevorderd 11/12/2009<br />
Auto <strong>CAD</strong> Optimalisatie 24/02/2010<br />
Auto <strong>CAD</strong> 2010 Certified Associate 31/05/2010<br />
Auto <strong>CAD</strong> 2010 Certified Professional 14/07/2010<br />
Auto <strong>CAD</strong> & VB.Net Basis 13/10/2010<br />
Auto <strong>CAD</strong> & VB.Net Gevorderd 28/10/2010.<br />
For the last months I was looking for graduation project ,I found this advertise<br />
Ontwerpprogramma<br />
Min. niveau: HBO<br />
Studierichting: Techniek<br />
Opleiding: Vrij studierichting HBO Techniek<br />
Type stage: Afstudeerstage<br />
Duur stage: 3 maanden<br />
Omschrijving:<br />
Als een Energiedak bij ons in opdracht wordt gegeven moet eerst een ontwerp worden<br />
gemaakt.<br />
Dit Gebeurt nu handmatig in AUTO<strong>CAD</strong>.<br />
Een erg tijdrovende bezigheid.<br />
Wij zijn op zoek naar een eigen Oplossing om geautomatiseerd een ontwerp tekunnen<br />
genereren.<br />
rekening houden met afschotlijnen in het dak,dakdoorbrekingen en de gebouwvorm. Het<br />
betreft hier een stage meer betrekking tot een aantal vakgebieden:<br />
-Installatietechniek.<br />
- Bouwkunde.<br />
-IT.<br />
Ideaal is een Installatietechnieker met IT affiniteit. Het betreft hier zeker niet alleen maar<br />
programmeren maar ook opzetten van een berekeningsmodule.<br />
Interesse?Reageer dan nu!<br />
I contacted them Immediately!<br />
By this repot I will clarify more details about the Energiedak® , SolarTech Company and them<br />
Problem and the solution.<br />
16/12/2010 ED<strong>CAD</strong>1.0 HBO-Traject 2010<br />
3
After the completion of the project the evaluation by the director was<br />
Athier heeft in ruim twee maanden tijd een ontwerp opgeleverd dat meer<br />
dan 100% voldoen aan onze opdracht en verwachtingen die wij hadden.<br />
gaandeweg de besprekingen werd duidelijk dat het probleem<br />
omvangrijker was dan wij in eerste instantie hadden voorzien. enkele<br />
keren liep hij tegen problemen aan waarvan in de praktijk nog geen<br />
oplossing voorhanden was en die hij zelf heeft moeten tackelen. het<br />
project heeft geen echte wijzigingen gekregen in aanpak, echter het is<br />
wel keer op keer uitgebreid en verder verfijnd, niet in de laatste plaats<br />
door athier zelf die meer en meer inzicht verkreeg in de materie en daar<br />
een goed passende oplossing voor wilde opleveren. het uiteindelijke<br />
programma werkt met tabbladen voor de hiervoor omschreven<br />
deelontwerpen, die afzonderlijk van elkaar en in combinatie van elkaar<br />
kunnen worden getoond. daarnaast levert het systeem een uiterst<br />
bruikbare stuklijst op voor de in het ontwerp te gebruiken materialen.<br />
Athier is met vlag en wimpel geslaagd in het leveren in het door<br />
SolarTech gewenste ontwerpprogramma. wij zijn hem zeer erkentelijk<br />
voor zijn inspanningen en zullen er met groot plezier en gemak gebruik<br />
van maken. wij wensen athier toe dat hij met hetzelfde enthousiasme<br />
aan het werk kan, gesteund door de bij SolarTech opgedane ervaring en<br />
kennis. wij bevelen hem dan ook van harte aan bij mogelijke<br />
opdrachtgevers die in de toekomst van zijn diensten gebruik willen<br />
maken.<br />
SolarTech International B.V. Eindhoven, 15 december 2010<br />
A.W.E. Schiebroek<br />
Directeur<br />
16/12/2010 ED<strong>CAD</strong>1.0 HBO-Traject 2010 4
Index<br />
1Introduction<br />
1.1 Auto<strong>CAD</strong> 6<br />
1.2 Autocad.NET 7<br />
1.3 About SolarTech 8<br />
1.4 Waht Is The Energiedak® 9<br />
2 The Problem Statement<br />
2.1 Analysis Of The Problem 13<br />
2.2 The Other Face Of The Problem 14<br />
2.3The Solution 14<br />
3 The Project<br />
3.1 Delineation of The Project 15<br />
3.2 Interface of The Projects 17<br />
4 ED<strong>CAD</strong>1.0<br />
4.1 What is ED<strong>CAD</strong>1.0 22<br />
4.2 The Auto<strong>CAD</strong> .dwg File 23<br />
4.3 Auto<strong>CAD</strong> Object Hierarchy 26<br />
4.4 ED<strong>CAD</strong>1.0 Details 27<br />
A - Afschotisolatie Palette 27<br />
The ToolTip 32<br />
B - Collectorleidingen Palette 33<br />
The ComboBoxes 38<br />
C-CollectorPlatenPalette 39<br />
E-PV-Module-Aanv.Reto.Palette 41<br />
The Bottom 43<br />
D- The Berekenen Palette 44<br />
F- The Afdrukken Palette 56<br />
Kader invullen 59<br />
Attachments 60<br />
Afterword 60<br />
16/12/2010 ED<strong>CAD</strong>1.0 HBO-Traject 2010 5
1 Introduction<br />
1.1 AUTO<strong>CAD</strong><br />
AUTO<strong>CAD</strong> is a general design tool in the designer's hands. The Customization<br />
includes modification or conversion of the universal usefulness into a particularized,<br />
customized application, which look after the repetitive and everyday operations<br />
forming them simpler in an automatized mode. The designer may demand average<br />
to high skill to control the <strong>CAD</strong> software.<br />
<strong>CAD</strong> operators take longer time to finish a series of tasks in an un-customized<br />
environment, while those <strong>CAD</strong> operators working in a customized environment will<br />
take comparatively lesser time to finish off the same series of tasks. With an uncustomized<br />
environment, operators are ineffective to take advantage of immediate<br />
menus and commands that they would typically use during the designing process.<br />
<strong>CAD</strong> operators process with a user interface that contributes no additional help to<br />
the characteristics that they normally use in their design.<br />
The software is typically left in its measure set of command, toolbars and menus.<br />
Automation of <strong>CAD</strong> is done essentially to minimize the time consumption and<br />
maximize the productivity.<br />
The Customization includes conversion or modification of the general utility into a<br />
specialized, tailor-made application, which takes care of routine and repetitive<br />
operations making them simpler in an automated manner.<br />
<strong>CAD</strong> Customization which gives you some of benefits likes:<br />
Increases the productivity.<br />
Faster Designs<br />
Accurate designs adhering to standards<br />
Consistent designs<br />
Ease of use, allowing low skilled manpower to handle design load<br />
Minimize errors<br />
Link <strong>CAD</strong> to other applications, such as Microsoft Excel and Access using the latest<br />
technologies<br />
Component Libraries<br />
Integration of Functions<br />
Structuring Requirements<br />
Custom Applications-<strong>CAD</strong><br />
16/12/2010 ED<strong>CAD</strong>1.0 HBO-Traject 2010 6
1.2 Autocad.net<br />
One of the greatest strengths of Autodesk products is the extensive Application<br />
programming Interface (API), which gives users the ability to customize and<br />
extend the functionality of the software. In the past, some favorite techniques<br />
included using Visual Lisp or VBA to create any needed customizations.<br />
Well, the good and bad news is that this decision has pretty much been made for<br />
us. Microsoft has deprecated VBA, and for several years now, has been pushing<br />
developers to drop VBA in favor of .NET. As a result, VBA will not be available<br />
inside of Auto<strong>CAD</strong> after the 2012 release, so VBA is no longer a good choice. And<br />
Autodesk has decided to concentrate only on the .NET API, so for the last couple<br />
of releases, we have only gotten new API functionality in the .NET API. And as<br />
time goes on, more and more functionality will be available only in the .NET API,<br />
We can use the Visual Studio Express Integrated Development Environment (IDE)<br />
to write our code.<br />
It gives us quite a few advantages :<br />
We have access to the Microsoft .NET framework, which contains tons of useful<br />
functionality. Not only does this framework give us access to all parts of Windows,<br />
it also gives us lots of utility classes, such as Lists, Dictionaries, Hash Sets, string<br />
parsing and formatting, advanced math functions, and more. Much of this stuff had<br />
to be hand-written in VBA and Visual Lisp. So the availability of the Microsoft .NET<br />
frameworks means that we often have to write a lot less custom code in order to<br />
get our custom applications working.<br />
We have full access to Windows Forms and Windows Presentation Framework<br />
(WPF), so we can create much more elaborate user interfaces than we could in<br />
Visual Lisp, or even in VBA.<br />
We have “Intellisense” in our IDEs, which makes it much easier to code. It lets us<br />
easily see what methods, properties, and events are available to any object, while<br />
we’re writing our code, and all we have to do is type the first few letters, and the<br />
rest is auto-typed for us.<br />
Our applications typically run faster. This may not matter for some routines, but<br />
can make a huge difference in other routines.<br />
A .NET application tends to be much more readable than a Lisp application,<br />
especially for large projects.<br />
And “more readable” means “more maintainable” – years later, when that original<br />
programmer is no longer around, and someone else needs to improve a routine or<br />
figure out why it stopped working, it’s much easier for the new programmer to<br />
parse a large .NET application than a large Lisp application.<br />
16/12/2010 ED<strong>CAD</strong>1.0 HBO-Traject 2010 7
.NET applications tend to be somewhat platform-independent, so the vast majority of<br />
the code will work on 32-bit and 64-bit systems, and on any Windows OS, with no<br />
issues.<br />
With attention that Visual Basic for Applications was only designed for 32-bit operating<br />
Systems!<br />
With our observation that LISP not affected and therefore remains available for use in<br />
the applications when we need it<br />
64-bit operating systems Used in most engineering companies, which means we really<br />
need to develop applications running on the new machines, even if we still use the old<br />
version of Autocad which support VBA we will not able to run VBA applications.<br />
It's time to move from 32-bit operating systems to 64-bit operating systems.<br />
It's time to stop Programming with VBA.<br />
It's .NET time.<br />
16/12/2010 ED<strong>CAD</strong>1.0 HBO-Traject 2010 8
1.3 About SolarTech.<br />
SolarTech International BV focuses in particular on the development of integrated<br />
Energieda® Solutions, including design, consulting and product development.<br />
SolarTech is a young company, established to the sustainability of the Energiedak®<br />
better market position than from the roofing industry would be possible.<br />
The Energiedak ® was developed by Schiebroek dakbedekkingen Best B.V, a patent on<br />
the system.<br />
SolarTech knowledge portal will be the roofing companies that Energiedak® to process.<br />
A.A.G. Schiebroek<br />
CommercialManager<br />
A.W.E. Schiebroek<br />
General Manager<br />
A.Alwekil<br />
Systemdeveloper<br />
Stagiaire<br />
In the previous period was Mr. Alexanderis in contact with me as well as Mr. André .<br />
I am not informed enough on the pyramid company.<br />
16/12/2010 ED<strong>CAD</strong>1.0 HBO-Traject 2010 9
1.4 What is the Energiedak®<br />
The Energiedak® heats during the day by sunlight and cool at night again.<br />
The top layer of the roof is dark colored and therefore highly absorbent roof covering.<br />
Below is a temperature conductive lines in the solar system that hides the roof.<br />
Through these pipes Flowing a liquid mixture that transports heat to heat a cold storage<br />
system.<br />
Here the heat is Stored until the moment when a short or long-term needs (eg night or in<br />
winter).<br />
The heat can be used in floor heating or to heat water.<br />
Conversely, the Energiedak® also contribute to the cooling of a building cooled by water to<br />
flow through the heating, eg during the night. By nocturnal heat radiation can be delivered<br />
through the Energiedak®.<br />
16/12/2010 ED<strong>CAD</strong>1.0 HBO-Traject 2010 10
Energiedak ®-Plus<br />
1 High Absorbent plastic roof covering<br />
2 Energiedak® collector plates with hose<br />
3 Receivers for Insulation U-value<br />
4 Bituminous vapor seal<br />
5 Building Construction, such as concrete or<br />
steel<br />
6 Plastic covering with roof integrated PV<br />
Modules<br />
Technical Data<br />
Pressure: 1.5 to 3.0 bar<br />
Flow: 2.5 to 3.5 l / min<br />
Resistance per section: 43.1 kPa<br />
System Weight: 4.16 Kg / m<br />
Fluid capacity: 0.9 l / m²<br />
Antifreeze: 0.27 l / m²<br />
1400 hours at full capacity 300 Wp<br />
Avg. yield Energiedak® 1.45 GJ / m²<br />
Avg. PV laminate yield: 63 Wp / m²<br />
16/12/2010 ED<strong>CAD</strong>1.0 HBO-Traject 2010 11
Service unit<br />
Bochtplaat collectorplaat collectorpiping PowerFastener<br />
PV modules<br />
16/12/2010 ED<strong>CAD</strong>1.0 HBO-Traject 2010<br />
12
2 The Problem Statement<br />
2.1 Analysis Of The Problem<br />
The drawing of the design for Energiedak® is fully manual line by line, and<br />
separately for each project and sometimes use different symbols and different<br />
colors which Indicate some important points in Energiedak®.<br />
Layers are used randomly.<br />
After considerable effort they got acceptable results with the continuation of the<br />
project readable only by the designer.<br />
They plot from the model space directly and they need drawing template for each<br />
project.<br />
Making the required calculations manually and the others are approximation.<br />
The designer does not have sufficient flexibility due to the use of traditional manual<br />
methods.<br />
Some project take time up to 80 hours for designing and drawing!!.<br />
We cannot depend on the DWG to achieve the project 100% ”after visiting to the<br />
workplace I have heard from the workers that the design is not completely<br />
accurate ” .<br />
16/12/2010 ED<strong>CAD</strong>1.0 HBO-Traject 2010 13
As we can see errors like this makes the design<br />
non-untrusted<br />
and the Length of pipe is calculated Manually!!<br />
Is it possible to trust the result with such large Tangled<br />
number of piping?<br />
With attachments :some drawing to clarify the<br />
previous situation.<br />
2.2 The Other Face Of The Problem<br />
We must know that The Energiedak® is performed on the roof by roofers,which<br />
was originally not familiar with such systems, And Since the system of several<br />
layers, it is desirable to those layers separately to show<br />
so there is therefore need for Very clear and precise design which can be seen<br />
how the roof should be made.<br />
Also there are 10 years warrenty, so We can consider the warranty period as one<br />
of the problems because of the absence of a clear and detailed diagrams which<br />
provide quick handling in case of repairing.<br />
2.3The Solution<br />
Program can solve all the problems, and It can be used by the operator even if does not<br />
have good experience with autocad!!, To do<br />
- Determination the required highest point of the roof slope<br />
- Placement Service units and distribution lines<br />
- Installation plan for collector plates<br />
- Installation plan for collector piping<br />
- Installation plan for PV panels<br />
- A list of materials and measurements, etc..<br />
Solar Tech specified its request<br />
No courses<br />
No simple customize<br />
Program meets all the requirements.<br />
16/12/2010 ED<strong>CAD</strong>1.0 HBO-Traject 2010 14
3 The Project<br />
3.1 Delineation of the project<br />
We must take into account when thinking about some of the technical points in the solution<br />
like<br />
Each service unit consist of maximum 8 groups piping "Circuit“.<br />
Maximum length for each group "Circuit" approximately 100m and the total for each unit<br />
approximately 800m .<br />
Which affect on the pumping system , so for the best design the designer has to know the<br />
length for each group from the beginning and he must able to change the design easily<br />
One collector plat can be used for two or more groups .<br />
We have to be able to close some of group in the service unit in case of emergency and<br />
In order to achieve this the design must be identical to the absolute reality in order to<br />
determine the group intended easily and quickly .<br />
Sure things that will be part of the solution are:<br />
Dynamic blocks with attributes.<br />
Custom hatches<br />
Using layers as much it's necessary.<br />
Templates are not part of solution (The main reason for that because we often begin<br />
work from an earlier drawing)<br />
Using Desile ,Script ,Macros , ImageTileMenus, CUIx files, Traditional Pallet, etc …can<br />
not be real useful , The main reason for that because<br />
A- some functionality are missing in autocad<br />
B-We need to make some calculations so we need a few routines<br />
The <strong>CAD</strong> operators must have basic knowledge of AutoCad , therefore they have to take<br />
a specific course on what they need to complete their work in a professional accuracy<br />
16/12/2010 ED<strong>CAD</strong>1.0 HBO-Traject 2010 15
It takes along time to clarify all the attempts what i have been through to resolve<br />
the problem because its complicated and takes along time.<br />
For example part of the project was the dynamic block , in the block editor<br />
environment we cannot array the array action, another action wel! .<br />
And we can apply multiple move action to the one segment but not array action.<br />
Attributes `` let we say is a segment in the dynamic block`` we can apply many<br />
actions like move, visibility to the attribute but not the array action same<br />
things for Xdata.<br />
Data instruction is function in auto cad we can use it to get many information<br />
but not the polyline length in the Block in specific layer just In case that<br />
the dynamic block is created in that specific layer not layer zero<br />
Conclusion :<br />
Data instruction is a powerful function In Auto<strong>CAD</strong> but cannot provide<br />
everything we need from the drawing.<br />
.NET is a powerful development environment I found the solution by using .NET<br />
to build ED<strong>CAD</strong>1.0 Dev. Tool.<br />
Through the following pages we will see more details.<br />
16/12/2010 ED<strong>CAD</strong>1.0 HBO-Traject 2010 16
3.2 Interface of The Projects<br />
The first question was wat type of Interface I will use<br />
Ribbon<br />
WinForms<br />
Palettes<br />
Ribbon<br />
Ribbon is the latest innovation in user interfaces. It was introduced by Microsoft in Office<br />
2007 and Autodesk followed in Auto<strong>CAD</strong> 2009. The Ribbon is created using the<br />
Windows Presentation Foundation (WPF) that is part of all Microsoft .NET<br />
Frameworks since 3.0.<br />
Ribbon: hosts all the content and is similar to a Windows Form Tab control<br />
RibbonBar: is similar to a TabPage in a Tab control but it can only contain<br />
RibbonPanels<br />
RibbonPanel: can contain rows (similar to toolbars), subpanels, panel separators,<br />
and controls. A RibbonPanel is intended to organize commands by task as seen<br />
above where all text related commands are in one panel, all draw related in<br />
another, etc.<br />
16/12/2010 ED<strong>CAD</strong>1.0 HBO-Traject 2010 17
It is very complicated to get all the features of ribbon may be for some case of<br />
few new routine we can use
So we can use it to active the command or may be to show WinForms.<br />
Summary<br />
Ribbon do not give enough space for the design of the application and because of the<br />
complexity of the ribbon.<br />
I think it does not help the new developers it is advanced stage<br />
16/12/2010 ED<strong>CAD</strong>1.0 HBO-Traject 2010 19
WinForms<br />
The application consisted of several forms so the final appearance of the application<br />
will be top, left and right sides of the Auto<strong>CAD</strong> drawing area which shrunk the drawing<br />
space….<br />
Shared f As New Form1<br />
Private Sub Button2_Click(ByVal sender As<br />
System.Object, ByVal e As System.EventArgs) Handles<br />
Button2.Click<br />
If f Is Nothing Then<br />
f = New Form1<br />
ElseIf f.IsDisposed Then<br />
f = New Form1<br />
End If<br />
Autodesk.Auto<strong>CAD</strong>.ApplicationServices.Application.Sho<br />
wModeless<strong>Dia</strong>log(f)<br />
End Sub<br />
16/12/2010 ED<strong>CAD</strong>1.0 HBO-Traject 2010<br />
20
Palettes<br />
We can use .NET usercontrol in the Palettes, and also we can auto hide to maximize the<br />
drawing space as well as contain multiple palettes to allow for organization of commands -<br />
concepts.<br />
It also made the processes easier to orchestrate by providing a work flow where the user<br />
interacts with the various tool<br />
Palettes instead of moving around between different dialog boxes.<br />
Summary<br />
Palettes has several features and its not complex and easy to make.<br />
Friend Shared palet As PaletteSet<br />
Public Sub startpalet()<br />
If palet = Nothing Then<br />
palet = New PaletteSet("ED<strong>CAD</strong>1.0 DVE.Tool for SolarTech ")<br />
palet.Add("Afschotisolatie", New UserControl1)<br />
palet.Add("Circuits", New UserControl2)<br />
palet.Add(" CollectorPlaten", New UserControl3)<br />
palet.Add("PV-Module-Aanv.Reto. ", New UserControl4)<br />
palet.Add("Berekenen ", New UserControl5)<br />
palet.Add("Afdrukken ", New UserControl6)<br />
End If<br />
palet.Visible = True<br />
End Sub<br />
16/12/2010 ED<strong>CAD</strong>1.0 HBO-Traject 2010<br />
21
4 ED<strong>CAD</strong>1.0<br />
4.1What is ED<strong>CAD</strong>1.0<br />
ED<strong>CAD</strong>1.0 was the project and the benefit obtained by SolarTech with the using of those<br />
tools which solve them problems are:<br />
1-Save drafting and designing time up to 90 % ‘as a proof I have designed project for<br />
Bredeschool in Ylpendam within two hours which usually takes with the traditional method<br />
about 40 hours.<br />
2-Accurate design adhering to standards by using blocks in component block library, costume<br />
hatches, etc.<br />
3-Easy to use, allowing low skilled cad operator can handle the design<br />
4-structuring work.<br />
5-Improve productivity.<br />
6-And thus increase profits.<br />
16/12/2010 ED<strong>CAD</strong>1.0 HBO-Traject 2010 22
4.2 The Auto<strong>CAD</strong> .dwg File.<br />
We could generalize the contents of that file as “The Document” and “The Database”.<br />
“The Document” contains document-wide properties (such as Dimension Variables), while<br />
the Database is comprised of Tables and Records. The Records reside inside the Tables.<br />
DesignSpace<br />
PropertiesSpace<br />
The Database<br />
DimStyleTable<br />
LineTypeTable<br />
Auto<strong>CAD</strong> .dwg File<br />
Tables Records<br />
The Document<br />
BlockTable ModelSpace<br />
LayerTable<br />
TextTable<br />
Layout(Pap.Spa.)<br />
X(BlockDefinition)<br />
LayerTableRe.<br />
TextStyleTableRe.<br />
DimStyleTableRe.<br />
LineTypeTableRe.<br />
16/12/2010 ED<strong>CAD</strong>1.0 HBO-Traject 2010 23
Practical example<br />
In order to see what of records we have in our drawing lets try this code<br />
_<br />
Public Sub ShowBTRs()<br />
Dim myDwg As Document = DocumentManager.MdiActiveDocument<br />
Using myTrans As Transaction = myDwg.TransactionManager.StartTransaction<br />
Dim myBT As BlockTable = _<br />
myDwg.Database.BlockTableId.GetObject(OpenMode.ForRead)<br />
For Each myBtrID As ObjectId In myBT<br />
Dim myBTR As BlockTableRecord = myBtrID.GetObject(OpenMode.ForRead)<br />
MsgBox(myBTR.Name)<br />
Next<br />
End Using<br />
End Sub<br />
For example we will see<br />
ModelSpace<br />
BlockTableRecord<br />
Layout<br />
BlockTableRecord<br />
LD is a BlockTableRecord for the<br />
Dynamic Blocks and *U37 is a<br />
BlockTableRecord which created<br />
automatically by Autocad after<br />
changing any Block Parameter.<br />
Its begin always with *U and the<br />
numbers after it is randomly each time<br />
we run the Autocad we must take into<br />
account that thing when we work with<br />
Selection Filters .<br />
*D38 Dimension BlockTableRecord in<br />
fact the Dimension in Autocad is kind of<br />
special Dynamic Blocks.<br />
Layout<br />
BlockTableRecord<br />
LD(BlockDefinition)<br />
BlockTableRecord<br />
Dimension<br />
BlockTableRecord<br />
؟؟؟؟؟؟<br />
BlockTableRecord<br />
*To see another TableRecord like LayerTableRecord or TextStyleTableRecord Just change the<br />
code As BlockTable to xxx As LayerTable, or xxx As TextStyleTable .<br />
16/12/2010 ED<strong>CAD</strong>1.0 HBO-Traject 2010 24
Sometime the same object has different Properties between the document and the<br />
database.<br />
An example of the difference between The Document and The Database is Create<br />
block in layer 0 when we insert the block in layer x in the Properties of the block we will<br />
see the layer name of the block is x, but in the database if we check it all the element of<br />
the block is in layer 0 it appears in the document in layer x and in the database not.<br />
Another example when we create block in layer A not in layer 0 and again change the<br />
layer to layer B it will changed in the document but not in the database ,as proof<br />
turnoff layer b …the block which originally created in layer A and moved to B will still<br />
on not off.<br />
Again if we `lock` the layer in the database it well locked well but not the Appearance<br />
of it in the document.<br />
In other words, some Properties not stored in the Database but elsewhere.<br />
Probably my nomination for this thing is not accurate(The document) but it is important<br />
to take it into account, to be used and to pay attention to what can happen from<br />
mistakes sometimes.<br />
Certainly I do not mean the difference between System Variable and Database<br />
Property, but as example, there is System Variable stored in the Drawing , like<br />
TEXTSTYLE.<br />
This means it is a Database Property and LAYLOCKFADECTL in the Registry<br />
Its not Database Property.<br />
Perhaps I can explain it by another example latter.<br />
Finally I found that development guide Auto<strong>CAD</strong> 2011give more information which can<br />
changing many things, I need a lot of time to read it and understand very well.<br />
.<br />
16/12/2010 ED<strong>CAD</strong>1.0 HBO-Traject 2010 25
4.3 Auto<strong>CAD</strong> Object Hierarchy<br />
Most of codes is builde on base of autocad Object Hierarachy .<br />
The following illustration shows the basic relationships between the Application object and<br />
an entity that is in a BlockTableRecord, such as Model space.<br />
There are many more objects in the Auto<strong>CAD</strong> .NET API that are not represented here.<br />
Entity<br />
1<br />
Application<br />
BlockTable<br />
BlockTableR<br />
ecord<br />
Entity<br />
2<br />
Document<br />
Maneger<br />
Entity<br />
…<br />
LayerTable<br />
LayerTableR<br />
ecord<br />
Document<br />
Databae<br />
Tables<br />
TextStyleTa<br />
ble<br />
TextTableR<br />
ecord<br />
16/12/2010 ED<strong>CAD</strong>1.0 HBO-Traject 2010 26
4.5 ED<strong>CAD</strong>1.0 Details<br />
A- Afschotisolatie Palette<br />
I will choose some Buttons and show parts of the code with<br />
some explanation<br />
If RadioButtonRIRV.Checked = True Then<br />
Autodesk.Auto<strong>CAD</strong>.ApplicationServices.Application.Document<br />
Manager.MdiActiveDocument.SendStringToExecute ("-<br />
HATCH" & vbCr & "P RIR12V 1 0 O D L N A S O ", True,<br />
False, False)<br />
Autodesk.Auto<strong>CAD</strong>.ApplicationServices.Application.UpdateSc<br />
reen()<br />
End If<br />
If RadioButtonRIRH.Checked = True Then<br />
Autodesk.Auto<strong>CAD</strong>.ApplicationServices.Application.Document<br />
Manager.MdiActiveDocument.SendStringToExecute ("-<br />
HATCH" & vbCr & "P RIR12H 1 0 O D L N A S O ", True,<br />
False, False)<br />
Autodesk.Auto<strong>CAD</strong>.ApplicationServices.Application.UpdateSc<br />
reen()<br />
RIR12V, RIR12H,etc, are custom hatches to make it<br />
Command: AI_EDITCUSTFILE<br />
Custom File to edit: acadiso.pat<br />
*RIR12V<br />
90,0,0,0,1200<br />
*RIR12H<br />
0,0,0,0,1000<br />
After that I used SendStringToExecute to write macros ! Nice<br />
and easy isnt it<br />
If RadioButtonRIRV.Checked = True Then<br />
PictureBoxRIRV.Visible = True<br />
PictureBoxRIRH.Visible = False<br />
PictureBoxEPSV.Visible = False<br />
PictureBoxEPSH.Visible = False<br />
End If<br />
Sure in the RadioButton event not in the PictureBoxevent<br />
we can also use one PictureBox to show multiple Picture by using<br />
PictureBox1.Image = My.Resources.PictureName<br />
.<br />
16/12/2010 ED<strong>CAD</strong>1.0 HBO-Traject 2010 27
SetSystemVariable("osmode", 547)<br />
INSERT.ExternBlok("C:\BLOCKS.dwg", "AFL")<br />
Dim x As String = "AFL"<br />
Dim doc =<br />
Autodesk.Auto<strong>CAD</strong>.ApplicationServices.Application.Document<br />
Manager.MdiActiveDocument<br />
Dim dwg = doc.Database<br />
Using transactie =<br />
dwg.TransactionManager.StartTransaction()<br />
Using doc.LockDocument()<br />
Dim acLyrTbl As LayerTable<br />
acLyrTbl = transactie.GetObject(dwg.LayerTableId,<br />
OpenMode.ForRead)<br />
If acLyrTbl.Has(x) = False Then<br />
Dim acLyrTblRec As LayerTableRecord = New<br />
LayerTableRecord()<br />
acLyrTblRec.Color =<br />
Color.FromColorIndex(ColorMethod.ByAci, 7)<br />
acLyrTblRec.Name = x<br />
acLyrTbl.UpgradeOpen()<br />
acLyrTbl.Add(acLyrTblRec)<br />
transactie.AddNewlyCreatedDBObject(acLyrTblRec, True)<br />
End If<br />
If acLyrTbl.Has(x) = True Then<br />
dwg.Clayer = acLyrTbl(x)<br />
transactie.Commit()<br />
End If<br />
End Using<br />
End Using<br />
Dim NAME As String = "AFL"<br />
Dim text = "(command ""insert"" ""AFL"" pause 1 1 0) "<br />
Autodesk.Auto<strong>CAD</strong>.ApplicationServices.Application.Document<br />
Manager.MdiActiveDocument.SendStringToExecute(text,<br />
True, False, True)<br />
Autodesk.Auto<strong>CAD</strong>.ApplicationServices.Application.UpdateSc<br />
reen()<br />
It work like this,<br />
In each time the operator ask for x block to tnsert it in the project the<br />
routine will check if the block is already exist if not the routine will<br />
import it from external dwg BLOCK.DWG which contain all the blocks<br />
used in the program this achieved by the Sub exterblok in Module<br />
INSERT<br />
16/12/2010 ED<strong>CAD</strong>1.0 HBO-Traject 2010 28
Dim NAME As String<br />
NAME = "AFL"<br />
Dim text = "(command ""insert"" ""AFL"" pause 1 1 0) "<br />
Autodesk.Auto<strong>CAD</strong>.ApplicationServices.Application.DocumentManager.MdiActi<br />
veDocument._<br />
SendStringToExecute(text, True, False, True)<br />
I used this method to insert blocks with attributes and field , but it does not work<br />
always well, it depends on the type of field ,field category objects -…field<br />
names…object does not work! After insert the block multiple times jest the last one<br />
will be correct!<br />
field category objects -…field names…NamedObject and BlockPlaceholder work good .<br />
In fact this method to inserting simple blocks not Dynamic blocks with attributes and<br />
field, its not the same as using commando insert manually, I will not use it in the next<br />
project ,it may cause big errors, The solution is to develop the Function InsertBlock in<br />
Module INSERT ‘I used it to insert bolck to a fixed point ‘ wich Is work 100% Except<br />
that the block is not hanging in the mouse cursor .<br />
16/12/2010 ED<strong>CAD</strong>1.0 HBO-Traject 2010 29
dwg.Clayer = acLyrTbl(N)<br />
transactie.Commit()<br />
End If<br />
End Using<br />
End Using<br />
Dim x, y As Double<br />
Dim l As Double<br />
l = Me.TextBoxL.Text<br />
Dim a As Double<br />
Dim k As Long<br />
If CheckBoxMax.CheckState =<br />
CheckState.Checked Then<br />
Dim b As Double<br />
b = Me.TextBoxMax.Text<br />
Dim c As Double<br />
c = Me.ComboBox1.Text<br />
If RadioButtonRIRH.Checked = True Then<br />
k = l / 1<br />
INSERT.EerstePunt "Waar wilt u het eerst<br />
nummer?", x1:=x, y1:=y)<br />
a = b + c<br />
For i = 1 To k<br />
a = a - c<br />
INSERT.Tekst ((a & "mm."), x, y, 400, 1.57)<br />
y = y + 1000<br />
Next<br />
End If<br />
If RadioButtonEPSH.Checked = True Then<br />
k = l / 1.2<br />
INSERT.EerstePunt(“Waar wilt u het eerst<br />
nummer?", x1:=x, y1:=y)<br />
a = b + c<br />
For i = 1 To k<br />
a = a - c<br />
INSERT.Tekst ((a & "mm."), x, y, 400, 1.57)<br />
y = y + 1200<br />
Next<br />
This routine Doing some calculations based on some data, and<br />
finally the type in the project by using some functions EerstePunt,<br />
Tekst and Element which is in Tekst functions all in Module INSERT<br />
16/12/2010 ED<strong>CAD</strong>1.0 HBO-Traject 2010 30
Public Function Tekst(ByVal regel As String, ByVal x As Double, ByVal y As Double,<br />
ByVal h As Double, ByVal r As Double) As ObjectId<br />
Dim objTekst As New DBText<br />
objTekst.SetDatabaseDefaults()<br />
objTekst.Position = New Point3d(x, y, 0)<br />
objTekst.Height = h<br />
objTekst.Rotation = r<br />
objTekst.TextString = regel<br />
objTekst.Color = Color.FromColorIndex(ColorMethod.ByAci, 1)<br />
Using myTrans As Transaction =<br />
ApplicationServices.Database.TransactionManager.StartTransaction<br />
Dim myTST As TextStyleTable =<br />
ApplicationServices.Database.TextStyleTableId.GetObject(OpenMode.ForRead)<br />
objTekst.TextStyleId = myTST("MYISODAK")<br />
myTrans.Commit()<br />
End Using<br />
Return INSERT.Element(objTekst)<br />
End Function<br />
Was created in an earlier part of the proceedings<br />
Dim<br />
Dim<br />
myTST<br />
myTST<br />
As<br />
As<br />
TextStyleTable<br />
TextStyleTable<br />
=<br />
=<br />
dwg.TextStyleTableId.GetObject(OpenMode.ForWrite)<br />
dwg.TextStyleTableId.GetObject(OpenMode.ForWrite)<br />
If<br />
If<br />
myTST.Has(S)<br />
myTST.Has(S)<br />
=<br />
=<br />
False<br />
False<br />
Then<br />
Then<br />
Dim<br />
Dim<br />
myTSTR<br />
myTSTR<br />
As<br />
As<br />
DatabaseServices.TextStyleTableRecord<br />
DatabaseServices.TextStyleTableRecord<br />
myTSTR<br />
myTSTR<br />
=<br />
=<br />
New<br />
New<br />
DatabaseServices.TextStyleTableRecord<br />
DatabaseServices.TextStyleTableRecord<br />
myTSTR.Name<br />
myTSTR.Name<br />
=<br />
=<br />
"MYISODAK"<br />
"MYISODAK"<br />
Dim<br />
Dim<br />
myFont<br />
myFont<br />
As<br />
As<br />
New<br />
New<br />
GraphicsInterface.FontDescriptor("ISOCPEUR",<br />
GraphicsInterface.FontDescriptor("ISOCPEUR",<br />
False,<br />
False,<br />
False,<br />
False,<br />
0,<br />
0,<br />
0)<br />
0)<br />
myTSTR.Font<br />
myTSTR.Font<br />
=<br />
=<br />
myFont<br />
myFont<br />
myTST.Add(myTSTR)<br />
myTST.Add(myTSTR)<br />
transactie.AddNewlyCreatedDBObject(myTSTR,<br />
transactie.AddNewlyCreatedDBObject(myTSTR,<br />
True)<br />
True)<br />
End<br />
End<br />
If<br />
If<br />
transactie.Commit()<br />
transactie.Commit()<br />
In fact it was possible to use SetSystemVariable("TEXTSTYLE", MYISODAK) so we can<br />
use Teks Function with more Style or to define it corrctly in the Function `ByVal S As<br />
String` to choice the style.<br />
Sometimes we cannot see the defects until after the completion of work, finally we can<br />
learn from the previous experiences.<br />
Function Element(ByVal entiteit As Entity) As ObjectId<br />
Dim doc = Application.DocumentManager.MdiActiveDocument<br />
Dim dwg = doc.Database<br />
Dim s As BlockTableRecord<br />
Using doc.LockDocument()<br />
Using transactie = doc.TransactionManager.StartTransaction()<br />
Try<br />
s = transactie.GetObject(dwg.CurrentSpaceId, OpenMode.ForWrite)<br />
Element = s.AppendEntity(entiteit)<br />
16/12/2010 ED<strong>CAD</strong>1.0 HBO-Traject 2010 31
transactie.AddNewlyCreatedDBObject(entiteit, True)<br />
transactie.Commit()<br />
Catch ex As Exception<br />
MsgBox("Er ging iets fout: " & vbCrLf & ex.Message)<br />
End Try<br />
End Using<br />
End Using<br />
End Function<br />
The ToolTip<br />
A tooltip is a small pop-up window that labels the unlabeled control being pointed<br />
to, such as unlabeled toolbar controls or command buttons ,which gives the user a<br />
little additional information regarding about the control and hoe to use it.<br />
Because we are going to design a program within a program A tooltip is useful.<br />
Once a ToolTip is added to the Palette (actually its UserControl) it appears at the bottom of<br />
the Palette window, not on the Palette ,it can be used by the other Controls on the same<br />
Palette.<br />
When a ToolTip has been added to the Palette, a new Property shows up in the Form’s<br />
other controls.<br />
Here we can see the property “ToolTip onToolTip1” for the Text Box we had already placed<br />
on the Form.<br />
16/12/2010 ED<strong>CAD</strong>1.0 HBO-Traject 2010 32
B- Collectorleidingen Palette<br />
Dim x As String<br />
x = Me.ComboBox1.Text<br />
Dim Lengte As Double = 0<br />
Dim TA As String = "NU"<br />
Me.Label5.Text = Lengte & "M"<br />
Dim Criterium(1) As TypedValue<br />
Criterium(0) = New TypedValue(DxfCode.Start, "INSERT")<br />
Criterium(1) = New TypedValue(DxfCode.LayerName, x)<br />
Dim ss As New SelectionFilter(Criterium)<br />
Dim Antwoord =<br />
Application.DocumentManager.MdiActiveDocument.Editor.Selec<br />
tAll(ss)<br />
If Antwoord.Status = PromptStatus.OK Then<br />
Dim col = New<br />
ObjectIdCollection(Antwoord.Value.GetObjectIds())<br />
Dim doc =<br />
Application.DocumentManager.MdiActiveDocument<br />
Dim dwg = doc.Database<br />
Using transactie =<br />
dwg.TransactionManager.StartTransaction()<br />
Using doc.LockDocument()<br />
Try<br />
For Each id In col<br />
Dim blokreferentie As BlockReference<br />
blokreferentie = transactie.GetObject(id,<br />
OpenMode.ForWrite)<br />
Dim AttRefIdColl =<br />
blokreferentie.AttributeCollection<br />
Dim BlokDefinities As BlockTable<br />
BlokDefinities =<br />
transactie.GetObject(dwg.BlockTableId, OpenMode.ForRead)<br />
Dim Blokdefid =<br />
BlokDefinities(blokreferentie.Name)<br />
Dim BlokDefinitie As BlockTableRecord<br />
BlokDefinitie = transactie.GetObject(Blokdefid,<br />
OpenMode.ForRead)<br />
For Each elementId In BlokDefinitie<br />
Dim Element As Entity<br />
Element = transactie.GetObject(elementId,<br />
OpenMode.ForRead)<br />
If Element.Visible = True Then<br />
If TypeOf Element Is Polyline Then<br />
Dim PL = CType(Element, Polyline)<br />
If PL.ConstantWidth = 18.9876 Then<br />
16/12/2010 ED<strong>CAD</strong>1.0 HBO-Traject 2010 33
Lengte = Lengte + FormatNumber((PL.Length / 1000), 2)<br />
End If<br />
End If<br />
End If<br />
Next<br />
Next id<br />
For Each id In col<br />
Dim blokreferentie As BlockReference<br />
blokreferentie = transactie.GetObject(id, OpenMode.ForWrite)<br />
Dim AttRefIdColl = blokreferentie.AttributeCollection<br />
For Each attRefId As ObjectId In AttRefIdColl<br />
Dim AttRef As AttributeReference<br />
AttRef = transactie.GetObject(attRefId, OpenMode.ForWrite)<br />
If AttRef.Tag.Equals(TA, StringComparison.OrdinalIgnoreCase) =<br />
True Then<br />
AttRef.TextString = Lengte<br />
Exit For<br />
End If<br />
Next<br />
Next id<br />
transactie.Commit()<br />
Catch ex As Exception<br />
MsgBox("Er ging iets fout: " & vbCrLf & ex.Message)<br />
End Try<br />
Me.Label5.Text = Lengte & "M"<br />
DocumentManager.MdiActiveDocument.Editor.Regen()<br />
End Using<br />
End Using<br />
End If<br />
Autodesk.Auto<strong>CAD</strong>.ApplicationServices.Application.UpdateScreen()<br />
This code to calculate the total lengths of the pipes<br />
for one "Circuit“.<br />
one "Circuit" can consists of multiple Dynamic<br />
Blocks which have multiple Parameters, actions<br />
and elements.<br />
It’s not possible to do it through the Parameter<br />
value, some pipes lengths are not be account in a<br />
Parameter.<br />
Calculate the Polyline length in a multiple Dynamic<br />
Blocks in a specific layer without exploded and see<br />
the result directly to modify the "Circuit" is the<br />
function of this routine which was missing in the<br />
autocad.<br />
We can use this code to get any information about<br />
the Dynamic Blocks more than befor.<br />
16/12/2010 ED<strong>CAD</strong>1.0 HBO-Traject 2010 34
Selection Filters<br />
we can use Selection Filters to limit which objects are selected and added to a selection<br />
set by using a selection filter, a selection filter list can be used to filter selected objects by<br />
properties or type.<br />
For example, we select only Blocks ( the type of block is "INSERT" to know the type<br />
small lisp do it (entget ( entlast)) or objects on a certain layer.<br />
I am not going to clarify deeply all details except one significant point that is the using of<br />
selection filters not easy as its look<br />
As example using 'Criterium(x) = New TypedValue(DxfCode.BlockName, "xxxx")<br />
it’s not work with Dynamic Blocks<br />
because of<br />
More details in page 24<br />
LD(BlockDefinition)<br />
BlockTableRecord<br />
؟؟؟؟؟؟<br />
BlockTableRecord<br />
Another example each element in the Selection set must have the property with or without<br />
same value but must have it.<br />
As example in one Selection set if there is one Polyline doesn’t have GlobalWidth<br />
(ConstantWidth) the code will not work<br />
This error happened when you changing the start width and the end width by the property<br />
windows GlobalWidth will be nothing also not 0 you have to set it manually<br />
and when start width not same the end width there will be no GlobalWidth(ConstantWidth)<br />
Then we should not use the condition (ConstantWidth) in the code of Selection Filters.<br />
16/12/2010 ED<strong>CAD</strong>1.0 HBO-Traject 2010 35
Dim x As String<br />
x = Me.ComboBox1.Text<br />
Dim doc = Application.DocumentManager.MdiActiveDocument<br />
Dim dwg = doc.Database<br />
Using transactie = dwg.TransactionManager.StartTransaction()<br />
Using doc.LockDocument()<br />
Dim acLyrTbl As LayerTable<br />
acLyrTbl=transactie.GetObject(dwg.LayerTableId,<br />
OpenMode.ForRead)<br />
If acLyrTbl.Has(x) = False Then<br />
Dim acLyrTblRec As LayerTableRecord = New<br />
LayerTableRecord()<br />
acLyrTblRec.Color =<br />
Color.FromColorIndex(ColorMethod.ByAci, 5)<br />
acLyrTblRec.Name = x<br />
acLyrTbl.UpgradeOpen()<br />
acLyrTbl.Add(acLyrTblRec)<br />
transactie.AddNewlyCreatedDBObject(acLyrTblRec, True)<br />
End If<br />
If acLyrTbl.Has(x) = True Then<br />
dwg.Clayer = acLyrTbl(x)<br />
If doc.Editor.SelectImplied.Status = PromptStatus.OK Then<br />
Dimcol=<br />
NewObjectIdCollection(doc.Editor.SelectImplied.Value.<br />
GetObjectIds)<br />
WijzigenLaag(col, x)<br />
End If<br />
transactie.Commit()<br />
End If<br />
End Using<br />
End Using<br />
Each time the operator choice "Circuit" form the ComboBoxe if its new (no exist) the<br />
routine will create Layer for it and in the end set it current.<br />
The advantage of this method is to have the required number of Layers<br />
(some Projects have 10 Layers "Circuit" and other Projects have 200 Layers "Circuit")<br />
Some time the operator want to copy exist "Circuit" to another place in the roof to be new<br />
"Circuit" with another name (the "Circuit" has the same name of its layer )<br />
As I said previousely they work from earliar drawing which may containe hundreds of<br />
layers and that will make the using of standard layermanager difficult with high risk of error<br />
and this code will do what they need from the standard layermanager with minimal errors<br />
16/12/2010 ED<strong>CAD</strong>1.0 HBO-Traject 2010 36
Sub WijzigenLaag(ByVal objIds As ObjectIdCollection, ByVal Laag As String)<br />
Dim doc = Application.DocumentManager.MdiActiveDocument<br />
Using doc.LockDocument()<br />
Using transactie = doc.TransactionManager.StartTransaction()<br />
Try<br />
For Each objId In objIds<br />
Dim Element As Entity<br />
Element = transactie.GetObject(objId, OpenMode.ForWrite)<br />
Element.Layer = Laag<br />
Next<br />
transactie.Commit()<br />
Catch ex As Exception<br />
MsgBox("Er ging iets fout: " & vbCrLf & ex.Message)<br />
End Try<br />
End Using<br />
End Using<br />
End Sub<br />
Each object has associated properties describe aspects of the individual object.<br />
Layer like color is properties, this code work on this base<br />
16/12/2010 ED<strong>CAD</strong>1.0 HBO-Traject 2010 37
The ComboBox<br />
ComboBox provide a space where the user can select a single item from a List.<br />
It is compact because it only expands to show more than one item when the user<br />
‘drops it down’.<br />
We can populate a ComboBox at run-time with code or at design-time using the Items<br />
property.<br />
Changing the DropDownStyle to a value of “DropDownList” will force the user to select<br />
something from the list.<br />
By default, users can select from the list or type in a different value.<br />
16/12/2010 ED<strong>CAD</strong>1.0 HBO-Traject 2010 38
C- CollectorPlaten Palette<br />
The DynamicBlock in this Pallte is simple and specific to avoid<br />
any design error.<br />
At the begging this block was part of the "Circuit" block "pipe"<br />
block but because one CollectorPlat can be contain pipes of<br />
two or more "Circuits" I made sprit block for it.<br />
16/12/2010 ED<strong>CAD</strong>1.0 HBO-Traject 2010 39
The Block<br />
Let us forget the codes and talk about the Block , DynamicBlock or StaticBlock is same<br />
they are block, and block is block like ModelSpace has Table and Block Table Records,<br />
and the (Block) has Block Table Record called BlockDefinitions.<br />
I think that I said nothing new until now, but to apply this concept in practice is what I'm<br />
seeing is very important.<br />
So we can create a powerful Dynamic Block especially with the ability to control the<br />
parameters values with .net.<br />
But ageing block is block like ModelSpace or PaperSpace we can draw, add entity, even<br />
insert block into the BlockDefinition(normally we can create Block in Block but we can not<br />
change the Parameter just ofter explod the Block with .NET we can do that with out<br />
exploded).<br />
The block can has several layers and the nice thing that we can turn of some of the block<br />
layers.<br />
I think understanding the Block is very important for any one wants to develop <strong>CAD</strong><br />
applications<br />
This block has three element ech one is in special layer, after insert the block in the<br />
modelspace if we turn of layer x the element x in the block will be of.<br />
Crating element not in layer 0 can give us let me say new Parameter.<br />
It’s not like the visibility parameter ,we can turn of special part of multiple block in one time<br />
and we can use it as Criterium in the SelectionFilter, it’s have another advantage like what<br />
I have been used in CollectorPlaten Blocks<br />
You can not changing the original layer of the Block (or part of it) if it was not layer 0<br />
To be more accurate, you can not changing the original layer (in the database) of the Block<br />
(or part of it) if it was not layer 0.<br />
16/12/2010 ED<strong>CAD</strong>1.0 HBO-Traject 2010 40
E- PV-Module-Aanv.Reto.Palette<br />
Dim doc =Autodesk.Auto<strong>CAD</strong>.ApplicationServices.Application. -<br />
Documen Manager.MdiActiveDocument<br />
Dim dwg = doc.Database<br />
Using transactie = dwg.TransactionManager.StartTransaction()<br />
Using doc.LockDocument()<br />
Dim S, C As String<br />
Dim A, B As Long<br />
S = "S"<br />
C = "C"<br />
A = 1<br />
B = 1<br />
For A = 1 To 20<br />
For B = 1 To 8<br />
Dim N As String<br />
N = [String].Concat(S, A, C, B)<br />
Dim acLyrTbl As LayerTable<br />
Dim acLyrTblRec As LayerTableRecord<br />
acLyrTbl = -<br />
transactie.GetObject(dwg.LayerTableId, OpenMode.ForRead)<br />
If acLyrTbl.Has(N) = True Then<br />
acLyrTblRec = New LayerTableRecord()<br />
acLyrTblRec.Name = N<br />
acLyrTbl.UpgradeOpen()<br />
acLyrTblRec =<br />
transactie.GetObject(acLyrTbl(N), _<br />
OpenMode.ForWrite)<br />
acLyrTblRec.IsOff = True<br />
End If<br />
Next<br />
Next<br />
transactie.Commit()<br />
End Using<br />
End Using<br />
This routine has tow (For . . . Next statements) used to repeat a block of code a specific<br />
number of times.<br />
For A represent the number of the service unite ,For B represent the number of the "Circuit" .<br />
That (block of cod)is to turn of the layer.<br />
Finally we can turn of a specific group of layer (could be 160) in one time.<br />
16/12/2010 ED<strong>CAD</strong>1.0 HBO-Traject 2010 41
Dim name As String<br />
name = ComboBox1.Text<br />
INSERT.ExternBlok("C:\BLOCKS.dwg", name)<br />
In the beginning of this routine I used the ComboBox items to<br />
Specify the name of the block, which will be effective in the four<br />
buttons, which saves a large area.<br />
More details in page 38<br />
There was a problem with PV-Modul ,Instead they do not have blocks for all kinds of it, the<br />
second must be placed over 100 mm.of the end of the first, etc.<br />
This problem was taking a lot of time, It was resolved very easy, As shown in the following<br />
pictures<br />
16/12/2010 ED<strong>CAD</strong>1.0 HBO-Traject 2010 42
The Bottom<br />
One of the most popular control in Visual Basic is the Button Control ,Appearance<br />
section of the properties window allows us to make changes to the appearance of the<br />
Button. With the help of Background Image properties we can set a background image<br />
to the button.<br />
Certainly we will choose Project resources file in order the (dll ) to work separately but we<br />
must bay attention aboutThe resource name (picture) .<br />
Do not import a resource has same name as another one already exist in the resources file<br />
with different uppercase and lowercase characters, otherwise we will get this error<br />
To avoid this error its better to but all the resources file in one map , so the windows will<br />
handle it to us.<br />
16/12/2010 ED<strong>CAD</strong>1.0 HBO-Traject 2010 43
D- The Berekenen Palette<br />
One of the benefit of using block is that we can use the block<br />
information to create reports and a bill of materials.<br />
Usually we used Link Excel, Access, SQL databases with<br />
Autocad, but In this situation me by its not the best choice, the<br />
main resin is that the information list is short.<br />
Another resin why tow files drawing + bill of material, if it can be<br />
one?<br />
In order to do that I made another block (Stuklijst Kader) with list<br />
of attributes and insert it in the PaperSpace.<br />
The advantage of that is keep the project in one file, update the<br />
list directly ,minimize the error, attributes is more static than<br />
Excel cells as example.<br />
Finally the application well no need any update when the<br />
company changing the version of Excel, Access.<br />
I will begin with the rotine which is in the event of<br />
UserControl5_Load (UserControl5 is Berekenen Palette)<br />
Dim Viewport As String = "Viewport"<br />
Dim name As String = "EnergieDakStuklijst"<br />
Part 1<br />
Dim name2 As String = "EnergieDakProject"<br />
INSERT.ExternBlok("C:\BLOCKS.dwg", "KaderA4")<br />
INSERT.ExternBlok("C:\BLOCKS.dwg", "KaderA3")<br />
Dim doc = Application.DocumentManager.MdiActiveDocument<br />
Dim myDB As Database = HostApplicationServices.WorkingDatabase<br />
Using myTrans As Transaction = myDB.TransactionManager.StartTransaction<br />
Using doc.LockDocument()<br />
Dim myBlockTable As BlockTable = myDB.BlockTableId.Get-<br />
Object(OpenMode.ForWrite)<br />
For Each myBTRid As ObjectId In myBlockTable<br />
Dim myBlockTableRecord As BlockTableRecord =<br />
myBTRid.GetObject(OpenMode.ForWrite)<br />
If myBlockTableRecord.IsLayout = True Then<br />
16/12/2010 ED<strong>CAD</strong>1.0 HBO-Traject 2010 44
Dim myLayout As Layout =<br />
myBlockTableRecord.LayoutId.GetObject(OpenMode.ForWrite)<br />
If myBlockTable.Has(name) = True Then<br />
Exit For<br />
End If<br />
Try<br />
myLayout =<br />
LayoutManager.Current.CreateLayout("EnergieDakStuklijst").GetObject(OpenMod<br />
e.ForWrite)<br />
LayoutManager.Current.CurrentLayout = "EnergieDakStuklijst"<br />
Dim col = New ObjectIdCollection<br />
col.Add(doc.Editor.SelectLast.Value.GetObjectIds(0))<br />
INSERT.Verwijderen(col)<br />
INSERT.InsertBlock(HostApplicationServices.WorkingDatabase,<br />
BlockTableRecord.PaperSpace, New Point3d(-5, -5, 0), "KaderA4", 1, 1, 1)<br />
Catch ex As Exception<br />
End Try<br />
Exit For<br />
End If<br />
Next<br />
PaperSpace has its own constant, BlockTableRecord.PaperSpace , and PaperSpace’s<br />
constant refers to the current PaperSpace Layout.<br />
So, the same Constant will provide different results based on which PaperSpace Layout we<br />
are working in.<br />
And when we creat new Layout its main we are working in it so we can set it current.<br />
The is One way to access the Layouts in a Database by them names is to use the<br />
LayoutDictionary, I use it in the next Palette we will see that later.<br />
Function Verwijderen(ByVal objIds As ObjectIdCollection) As Boolean<br />
Dim doc = Application.DocumentManager.MdiActiveDocument<br />
Dim dwg = doc.Database<br />
Using transactie = doc.TransactionManager.StartTransaction()<br />
Try<br />
Dim s As BlockTableRecord<br />
s = transactie.GetObject(dwg.CurrentSpaceId, OpenMode.ForWrite)<br />
For Each objId In objIds<br />
Dim Element As Entity<br />
Element = transactie.GetObject(objId, OpenMode.ForWrite)<br />
Element.Erase()<br />
Next<br />
transactie.Commit()<br />
Catch ex As Exception<br />
MsgBox("Er ging iets fout: " & vbCrLf & ex.Message)<br />
End Try<br />
End Using<br />
End Function<br />
Part 2<br />
It’s to delete the viewport for EnergieDakStuklijst Layout, which is the last element in the<br />
Layout creation progress .<br />
16/12/2010 ED<strong>CAD</strong>1.0 HBO-Traject 2010 45
Dim acLyrTbl As LayerTable<br />
acLyrTbl = myTrans.GetObject(myDB.LayerTableId, OpenMode.ForRead)<br />
If acLyrTbl.Has(Viewport) = False Then<br />
Dim acLyrTblRec As LayerTableRecord = New LayerTableRecord()<br />
acLyrTblRec.Color = Color.FromColorIndex(ColorMethod.ByAci, 4)<br />
acLyrTblRec.Name = Viewport<br />
acLyrTblRec.IsPlottable = False<br />
acLyrTbl.UpgradeOpen()<br />
acLyrTbl.Add(acLyrTblRec)<br />
myTrans.AddNewlyCreatedDBObject(acLyrTblRec, True)<br />
End If<br />
If acLyrTbl.Has(Viewport) = True Then<br />
myDB.Clayer = acLyrTbl(Viewport)<br />
End If<br />
For Each myBTRid As ObjectId In myBlockTable<br />
Dim myBlockTableRecord As BlockTableRecord =<br />
myBTRid.GetObject(OpenMode.ForWrite)<br />
If myBlockTableRecord.IsLayout = True Then<br />
Dim myLayout As Layout =<br />
myBlockTableRecord.LayoutId.GetObject(OpenMode.ForWrite)<br />
If myBlockTable.Has(name2) = True Then<br />
LayoutManager.Current.CurrentLayout = "EnergieDakProject"<br />
Exit For<br />
End If<br />
Try<br />
myLayout = LayoutManager.Current.-<br />
CreateLayout("EnergieDakProject").GetObject(OpenMode.ForWrite)<br />
LayoutManager.Current.CurrentLayout = "EnergieDakProject"<br />
INSERT.InsertBlock(HostApplicationServices.WorkingDatabase, -<br />
BlockTableRecord.PaperSpace, New Point3d(0, 0, 0), "KaderA3", 1, 1, 1)<br />
Catch ex As Exception<br />
End Try<br />
Exit For<br />
End If<br />
Next<br />
myDB.Clayer = acLyrTbl(0)<br />
myTrans.Commit()<br />
End Using<br />
End Using<br />
Application.SetSystemVariable("tilemode", 1)<br />
Part 3<br />
We chick the BlockTable tow time to create tow Layouts and insert themes<br />
Blocks(KaderA4,KaderA3) during the procedure I create layer Viewport to set the view<br />
port for EnergieDakProject Layout in.<br />
And fainlly set layer 0 which is already in any drawing as current layer and then return<br />
to the ModelSpace.<br />
16/12/2010 ED<strong>CAD</strong>1.0 HBO-Traject 2010 46
I use the right method to insert the block (Function InsertBlock) not by<br />
Autodesk.Auto<strong>CAD</strong>.ApplicationServices.Application.DocumentManager.MdiActiveDocu<br />
ment.SendStringToExecute("-i" & vbCr & "KaderA4" & vbCr & "0,0" & vbCr & "1" & vbCr<br />
& "0", True, False, False)<br />
Autodesk.Auto<strong>CAD</strong>.ApplicationServices.Application.DocumentManager.MdiActiveDocu<br />
ment.SendStringToExecute("1 0 1", True, False, False)<br />
Its work good ,but we will not able to edit in place the attribute by double click on it .<br />
We will lock in (Function InsertBlock) in the next page.<br />
The resin why I but this routine in the load event is that in each button in the Berekken<br />
Palette the result we be send directly to,<br />
A-label in the Palette.<br />
B-update Attributes in the Stuklijst Layout.<br />
16/12/2010 ED<strong>CAD</strong>1.0 HBO-Traject 2010 47
Public Function InsertBlock(ByVal DatabaseIn As Database, _<br />
ByVal BTRToAddTo As String,ByVal InsPt As Geometry.Point3d, _<br />
ByVal BlockName As String,ByVal XScale As Double,ByVal YScale As Double,_<br />
ByVal ZScale As Double) As DatabaseServices.ObjectId<br />
Using myTrans As Transaction=DatabaseIn.TransactionManager.StartTransaction<br />
Dim myBlockTable As BlockTable= _<br />
DatabaseIn.BlockTableId.GetObject(OpenMode.ForRead)<br />
If myBlockTable.Has(BlockName) = False Then<br />
Return Nothing<br />
1<br />
End If<br />
If myBlockTable.Has(BTRToAddTo) = False Then<br />
Return Nothing<br />
End If<br />
Dim myBlockDef As BlockTableRecord = _<br />
myBlockTable(BlockName).GetObject(OpenMode.ForRead)<br />
Dim myBlockTableRecord As BlockTableRecord = _<br />
myBlockTable(BTRToAddTo).GetObject(OpenMode.ForWrite)<br />
Dim myBlockRef As New BlockReference(InsPt, myBlockDef.Id)<br />
myBlockRef.ScaleFactors = New Geometry.Scale3d(XScale, YScale, ZScale)<br />
myBlockTableRecord.AppendEntity(myBlockRef)<br />
myTrans.AddNewlyCreatedDBObject(myBlockRef, True)<br />
Dim myAttColl As DatabaseServices.AttributeCollection = _<br />
myBlockRef.AttributeCollection<br />
For Each myEntID As ObjectId In myBlockDef<br />
Dim myEnt As Entity = myEntID.GetObject(OpenMode.ForRead)<br />
If TypeOf myEnt Is DatabaseServices.AttributeDefinition Then<br />
Dim myAttDef As DatabaseServices.AttributeDefinition = myEnt<br />
Dim myAttRef As New DatabaseServices.AttributeReference<br />
myAttRef.SetAttributeFromBlock(myAttDef, myBlockRef.BlockTransform)<br />
myAttColl.AppendAttribute(myAttRef)<br />
myTrans.AddNewlyCreatedDBObject(myAttRef, True)<br />
End If<br />
Next<br />
myTrans.Commit()<br />
Return myBlockRef.Id<br />
End Using<br />
End Function<br />
1- We are able to specifying the BlockTableRecord which we want to insert the block in the<br />
ModelSpace, PaperSpace, or even another BlockDefinition (see page 40)<br />
2- We loops through each entity in a Block Definition, looking for an AttributeDefinition entity.<br />
If we find an AttributeDefinition, we create a new AttributeReference based on the Definition<br />
and append the AttributeReference to the AttributeCollection of the BlockReference.<br />
But what dose this main, is it Maine that Attribute like akind of Block in Block, I think it’s like<br />
that.<br />
What important to me is BlockReference which is in another word Block name and the<br />
AttributeReference they are not the same and that affect on the SelectionFilter Criterium.<br />
In the next page a practicl exampel.<br />
16/12/2010 ED<strong>CAD</strong>1.0 HBO-Traject 2010 48<br />
2
Dim Criterium(1) As TypedValue<br />
Criterium(0) = New TypedValue(DxfCode.Start, "INSERT")<br />
'Criterium(1) = New TypedValue(DxfCode.BlockName, "SU")<br />
Dim ss As New SelectionFilter(Criterium)<br />
Dim Antwoord = Application.DocumentManager.-<br />
MdiActiveDocument.Editor.SelectAll(ss)<br />
If Antwoord.Status = PromptStatus.OK Then<br />
Dim col = New ObjectIdCollection(Antwoord.Value.GetObjectIds())<br />
Dim doc = Application.DocumentManager.MdiActiveDocument<br />
Dim dwg = doc.Database<br />
Using transactie = dwg.TransactionManager.StartTransaction()<br />
Using doc.LockDocument()<br />
Try<br />
For Each id In col<br />
Dim blokreferentie As BlockReference<br />
blokreferentie = transactie.GetObject(id, OpenMode.ForRead)<br />
Dim BlokDefinities As BlockTable<br />
BlokDefinities =<br />
transactie.GetObject(dwg.BlockTableId, OpenMode.ForRead)<br />
Dim Blokdefid = BlokDefinities(blokreferentie.Name)<br />
If blokreferentie.Name = "SU" Then<br />
TotaalServicunits = TotaalServicunits + 1<br />
End If<br />
Next id<br />
'GET ATTRE<br />
For Each id In col<br />
Dim blokreferentie As BlockReference<br />
blokreferentie = transactie.GetObject(id, OpenMode.ForWrite)<br />
Dim AttRefIdColl = blokreferentie.AttributeCollection<br />
For Each attRefId As ObjectId In AttRefIdColl<br />
Dim AttRef As AttributeReference<br />
AttRef = transactie.GetObject(attRefId, OpenMode.ForWrite)<br />
If AttRef.Tag.Equals(TA, StringComparison.OrdinalIgnoreCase) =<br />
True Then<br />
AttRef.TextString = TotaalServicunits & “ Stuk"<br />
Exit For<br />
End If<br />
Next<br />
Next id<br />
Its the proof about what I have said in the last page about the BlockReference and the<br />
AttributeReference.<br />
When we add the 'Criterium(1) = New TypedValue(DxfCode.BlockName, "SU") in the<br />
SelectionFilter we will be not able to get the AttributeReference and that make me think that<br />
the Attribute let me say linked to the block .<br />
And the type of Attribute is "INSERT“ it’s a block. Its in the data base separated block in one<br />
tabel with the block which linked with.<br />
16/12/2010 ED<strong>CAD</strong>1.0 HBO-Traject 2010 49
Notice : this is the page nember 50 and some routine in this palette can take several pages so I<br />
shall show parts of each routine.<br />
Berekenen Totaal Circuits Lengte (Paiping) see page 12<br />
Dim TA As String = "TotaalCollectorbuis"<br />
Dim TOTAALOPV As String = "TOTAALOPV"<br />
Dim Lengte As Double = 0<br />
Me.Label1.Text = (Lengte & " M")<br />
Dim Criterium(0) As TypedVal<br />
Criterium(0) = New TypedValue(DxfCode.Start, "INSERT")<br />
'Criterium(1) = New TypedValue(DxfCode.LayerName, x)<br />
Dim ss As New SelectionFilter(Criterium)<br />
This routine is nearly the same routine of the Berekken button in the Collectorleidingen<br />
Palette With some additions.<br />
Berekenen Totaal Bocht Platen see page 12<br />
Try<br />
For Each id In col<br />
Dim blokreferentie As BlockReference<br />
blokreferentie = transactie.GetObject(id, OpenMode.ForRead)<br />
Dim BlokDefinities As BlockTable<br />
BlokDefinities = transactie.GetObject(dwg.BlockTableId, OpenMode.ForRead)<br />
Dim Blokdefid = BlokDefinities(blokreferentie.Name)<br />
Dim BlokDefinitie As BlockTableRecord<br />
BlokDefinitie = transactie.GetObject(Blokdefid, OpenMode.ForRead)<br />
'Block PD<br />
For Each elementId In BlokDefinitie<br />
Dim Element As Entity<br />
Element = transactie.GetObject(elementId, OpenMode.ForRead)<br />
If Element.Visible = True Then<br />
If TypeOf Element Is Polyline Then<br />
Dim PL = CType(Element, Polyline)<br />
If PL.ConstantWidth = 2.6789 Then<br />
If PL.ColorIndex = 171 Then<br />
TotaalBochtPlaten = TotaalBochtPlaten + 2<br />
End If<br />
End If<br />
End If<br />
End If<br />
Next<br />
'Block LD<br />
For Each elementId In BlokDefinitie<br />
Dim Element As Entity<br />
Element = transactie.GetObject(elementId, OpenMode.ForRead)<br />
If Element.Visible = True Then<br />
If TypeOf Element Is Polyline Then<br />
Dim PL = CType(Element, Polyline)<br />
If PL.ConstantWidth = 3.6789 Then<br />
If PL.ColorIndex = 169 Then<br />
TotaalBochtPlaten = TotaalBochtPlaten + 0.25<br />
16/12/2010 ED<strong>CAD</strong>1.0 HBO-Traject 2010 50
What is this<br />
If Element.Visible = True Then<br />
If TypeOf Element Is Polyline Then<br />
Dim PL = CType(Element, Polyline)<br />
If PL.ConstantWidth = 2.6789 Then<br />
If PL.ColorIndex = 171 Then<br />
TotaalBochtPlaten = TotaalBochtPlaten + 2<br />
It’s a small Polyline with unique ConstantWidth and ColorIndex values for each block to<br />
make some calculation.<br />
It’s like Parameter.<br />
It was the easier way to get the required information, but way not Attribute or Xdata ?<br />
Because we are working with Dynamic Block with (some time ArrayAction), we cannot<br />
Array the Attribute or Xdata.<br />
And way ConstantWidth and ColorIndex properties?<br />
Not all properties work ,as example circle with special radius or Polyline..Length<br />
will not work.<br />
And way that ?<br />
Its take a time to know that and to check all kind of Objects properties.<br />
See page 25<br />
16/12/2010 ED<strong>CAD</strong>1.0 HBO-Traject 2010 51
Berekenen Totaal CollectorPlaten see page 12<br />
'Block PL<br />
For Each elementId In BlokDefinitie<br />
Dim Element As Entity<br />
Element = transactie.GetObject(elementId, OpenMode.ForRead)<br />
If Element.Visible = True Then<br />
If TypeOf Element Is Polyline Then<br />
Dim PL = CType(Element, Polyline)<br />
If PL.ConstantWidth = 5.6789 Then<br />
If PL.ColorIndex = 58 Then<br />
TotaalSysteemplaten = TotaalSysteemplaten + 1<br />
End If<br />
End If<br />
End If<br />
End If<br />
Next<br />
'Block PL21<br />
For Each elementId In BlokDefinitie<br />
Dim Element As Entity<br />
Element = transactie.GetObject(elementId, OpenMode.ForRead)<br />
If Element.Visible = True Then<br />
If TypeOf Element Is Polyline Then<br />
Dim PL = CType(Element, Polyline)<br />
If PL.ConstantWidth = 13 Then<br />
If PL.ColorIndex = 65 Then<br />
TotaalSysteemplaten = TotaalSysteemplaten + 0.0625<br />
End If<br />
End If<br />
End If<br />
End If<br />
Next<br />
This number is the result of calculating the block area and compare it with the area of<br />
one complete CollectorPlaten.<br />
Berekenen Totaal Power Fastener see page 12<br />
Berekenen Totaal Aanv.reto.leiding<br />
Berekenen Totaal PV-Platen see page 12<br />
Nothing new in them routines they use same idea with some differences.<br />
16/12/2010 ED<strong>CAD</strong>1.0 HBO-Traject 2010 52
The first version of the Aanvoer en retourleiding Block was like<br />
this.<br />
(Part of the Block)<br />
But they need o culculte the length for each diameter, I change it to separated Block and<br />
with this routine we will get what they asked, this part of it.<br />
Dim diktes = New List(Of String)<br />
Dim Lengtes = New List(Of Double)<br />
Dim Criterium(1) As TypedValue<br />
Criterium(0) = New TypedValue(DxfCode.Start, "INSERT")<br />
Dim ss As New SelectionFilter(Criterium)<br />
Dim Antwoord = Application.DocumentManager.MdiActiveDocument.Editor.SelectAll(ss)<br />
If Antwoord.Status = PromptStatus.OK Then<br />
Dim col = New ObjectIdCollection(Antwoord.Value.GetObjectIds())<br />
Dim doc = Application.DocumentManager.MdiActiveDocument<br />
Dim dwg = doc.Database<br />
Using transactie = dwg.TransactionManager.StartTransaction()<br />
Using doc.LockDocument()<br />
Try<br />
For Each id In col<br />
Dim blokreferentie As BlockReference<br />
blokreferentie = transactie.GetObject(id, OpenMode.ForWrite)<br />
Dim AttRefIdColl = blokreferentie.AttributeCollection<br />
Dim AttribuutAVanDitBlok = ""<br />
For Each attRefId As ObjectId In AttRefIdColl<br />
Dim AttRef As AttributeReference<br />
AttRef = transactie.GetObject(attRefId, OpenMode.ForWrite)<br />
If AttRef.Tag.Equals(a, StringComparison.OrdinalIgnoreCase) = True Then<br />
AttribuutAVanDitBlok = AttRef.TextString<br />
16/12/2010 ED<strong>CAD</strong>1.0 HBO-Traject 2010 53
This routine work like this,<br />
in the begining we define tow ArrayList t "List(Of Type)" , we can considerd the Array list as<br />
kind of collections.<br />
Because we do not know the size of the array, so the ArrayList will grow dynamically<br />
And then we define string AttribuutAVanDitBlok which will get the value of dik Attribuute.<br />
Dim KomtVoor = False<br />
For Each dik In diktes<br />
If dik = AttRef.TextString Then KomtVoor = True<br />
Next<br />
If Not KomtVoor Then<br />
diktes.Add(AttRef.TextString)<br />
Lengtes.Add(0)<br />
End If<br />
End If<br />
If AttRef.Tag.Equals(b, StringComparison.OrdinalIgnoreCase) = True Then<br />
For i = 0 To diktes.Count - 1<br />
If AttribuutAVanDitBlok = diktes(i) Then<br />
Lengtes.Item(i) = Lengtes.Item(i) + AttRef.TextString<br />
End If<br />
Next<br />
End If<br />
Next<br />
Hier we check first if there is a previous dik in the Array diktes if not we will add the<br />
new value and then we check the dik if it is same we will add the Lengtes to the old<br />
one.<br />
Dim LaatstePlaats = 450<br />
For i = 0 To diktes.Count - 1<br />
Dim c1 = New System.Windows.Forms.Label<br />
c1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D<br />
c1.BackColor = Ivory<br />
c1.AutoSize = True<br />
c1.Name = "<strong>Dia</strong>meter" & i<br />
c1.Text = diktes(i) & " " & Lengtes(i)<br />
c1.Left = 25<br />
LaatstePlaats = LaatstePlaats + 30<br />
c1.Top = LaatstePlaats<br />
Me.Controls.Add(c1)<br />
Me.Controls("<strong>Dia</strong>meter" & i).Text = "Dik is " & diktes(i) & "mm" & " Lengte is " & (2 * L<br />
engtes(i)) & "M"<br />
Next<br />
Me.Update()<br />
Next id<br />
The laste part is for create the lable in the Paltte.<br />
16/12/2010 ED<strong>CAD</strong>1.0 HBO-Traject 2010 54
For i = 0 To diktes.Count - 1<br />
Dim TA As String = [String].Concat("DIKTE", i)<br />
For Each id In col<br />
Dim blokreferentie As BlockReference<br />
blokreferentie = transactie.GetObject(id,<br />
OpenMode.ForWrite)<br />
Dim AttRefIdColl = blokreferentie.AttributeCollection<br />
For Each attRefId As ObjectId In AttRefIdColl<br />
Dim AttRef As AttributeReference<br />
AttRef = transactie.GetObject(attRefId,<br />
OpenMode.ForWrite)<br />
If AttRef.Tag.Equals(TA,<br />
StringComparison.OrdinalIgnoreCase) = True Then<br />
AttRef.TextString = "Dik is " & diktes(i) & "mm" & " Lengte<br />
is " & (2 * Lengtes(i)) & "M"<br />
Exit For<br />
End If<br />
Next<br />
This for the Attibuutes in the Stuklijst.<br />
16/12/2010 ED<strong>CAD</strong>1.0 HBO-Traject 2010 55
F- The Afdrukken Palette<br />
One way to access the Layouts in a Database is to use the<br />
LayoutDictionary.<br />
In this routien,we open the LayoutDictionary get the current<br />
Layout Name (EnergieDakStuklijst), and then we ask the<br />
LayoutDictionary if it has an entry with an EntryName that is the<br />
same as the current<br />
layout’s name , it’s the different between BlockTableRecord<br />
names(*Model_Space, *Paper_Space, *Paper_Space0) and<br />
Layout Names (Model, Layout1, Layout2).<br />
Its work perfectly I use it to switch to Model , EnergieDakStuklijst-<br />
Layout , EnergieDakProject.<br />
Dim doc = Autodesk.Auto<strong>CAD</strong>.ApplicationServices.Application.<br />
DocumentManager.MdiActiveDocument<br />
Dim myDB As Database =<br />
HostApplicationServices.WorkingDatabase<br />
Using myTrans As Transaction =<br />
myDB.TransactionManager.StartTransaction<br />
Using doc.LockDocument()<br />
Dim myBlockTable As BlockTable =<br />
myDB.BlockTableId.GetObject(OpenMode.ForWrite)<br />
For Each myBTRid As ObjectId In myBlockTable<br />
Dim myDictionary As DBDictionary =<br />
myDB.LayoutDictionaryId.GetObject(OpenMode.ForRead)<br />
Dim EnergieDakStuklijst As String =<br />
LayoutManager.Current.CurrentLayout<br />
If myDictionary.Contains(EnergieDakStuklijst) Then<br />
Try<br />
Dim myLayoutID As ObjectId =<br />
myDictionary(EnergieDakStuklijst)<br />
Dim myLayout As Layout =<br />
myLayoutID.GetObject(OpenMode.ForRead)<br />
Dim myBTR As BlockTableRecord =<br />
myLayout.BlockTableRecordId.GetObject(OpenMode.ForWrite)<br />
LayoutManager.Current.CurrentLayout =<br />
"EnergieDakStuklijst"<br />
Exit For<br />
Catch ex As Exception<br />
End Try<br />
End If<br />
Next<br />
myTrans.Commit()<br />
DocumentManager.MdiActiveDocument.Editor.Regen()<br />
End Using<br />
End Using<br />
16/12/2010 ED<strong>CAD</strong>1.0 HBO-Traject 2010 56
Dim acLyrTbl As LayerTable<br />
Dim acLyrTblRec As LayerTableRecord<br />
acLyrTbl =transactie.GetObject(dwg.LayerTableId,<br />
OpenMode.ForRead)<br />
Try<br />
If acLyrTbl.Has(Afschotplan) = True Then<br />
acLyrTblRec = New LayerTableRecord()<br />
acLyrTblRec.Name = Afschotplan<br />
acLyrTbl.UpgradeOpen()<br />
acLyrTblRec = transactie.GetObject(acLyrTbl(Afschotplan),<br />
OpenMode.ForWrite)<br />
acLyrTblRec.IsOff = False<br />
End If<br />
If acLyrTbl.Has(AFL) = True Then<br />
acLyrTblRec = New LayerTableRecord()<br />
acLyrTblRec.Name = AFL<br />
acLyrTbl.UpgradeOpen()<br />
acLyrTblRec = transactie.GetObject(acLyrTbl(AFL), _<br />
OpenMode.ForWrite)<br />
acLyrTblRec.IsOff = False<br />
End If<br />
The function of these Radio Buttons is turn of group of layers, except the first one which I<br />
used it to choice which layout will be print, EnergieDakStuklijst Layout if Checked = True ore<br />
EnergieDakProject Layout if Checked = False.<br />
This routine work like this.<br />
First we look for some Attributes and get them values to use it as part of plot file name, and<br />
then we set the required Layout current and begin the plot progress .<br />
Its along routine I will begin directly with the plot progress.<br />
Dim acDoc As Document = Autodesk.Auto<strong>CAD</strong>.ApplicationServices.<br />
Application.DocumentManager.MdiActiveDocument<br />
Dim acCurDb As Database = acDoc.Database<br />
Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction()<br />
Using doc.LockDocument()<br />
Dim acLayoutMgr As LayoutManager<br />
acLayoutMgr = LayoutManager.Current<br />
Dim acLayout As Layout<br />
acLayout = acTrans.GetObject(acLayoutMgr.GetLayoutId(acLayoutMgr.CurrentLayout), _<br />
OpenMode.ForRead)<br />
Dim acPlInfo As PlotInfo = New PlotInfo()<br />
acPlInfo.Layout = acLayout.ObjectId<br />
Dim acPlSet As PlotSettings = New PlotSettings(acLayout.ModelType)<br />
acPlSet.CopyFrom(acLayout)<br />
Dim acPlSetVdr As PlotSettingsValidator = PlotSettingsValidator.Current<br />
acPlSetVdr.SetPlotType(acPlSet, _<br />
Autodesk.Auto<strong>CAD</strong>.DatabaseServices.PlotType.Layout)<br />
16/12/2010 ED<strong>CAD</strong>1.0 HBO-Traject 2010 57
acPlSetVdr.SetUseStandardScale(acPlSet, True)<br />
acPlSetVdr.SetStdScaleType(acPlSet, StdScaleType.StdScale1To1)<br />
acPlSetVdr.SetPlotOrigin(acPlSet, New Point2d(0, 0))<br />
acPlSetVdr.SetPlotConfigurationName(acPlSet, "Dwg to pdf.pc3", _<br />
"iso_A3_(420.00_x_297.00_mm)")<br />
acPlInfo.OverrideSettings = acPlSet<br />
Dim acPlInfoVdr As PlotInfoValidator = New PlotInfoValidator()<br />
acPlInfoVdr.MediaMatchingPolicy = MatchingPolicy.MatchEnabled<br />
acPlInfoVdr.Validate(acPlInfo)<br />
If PlotFactory.ProcessPlotState = Autodesk.Auto<strong>CAD</strong>.PlottingServices. _<br />
ProcessPlotState.NotPlotting Then<br />
Using acPlEng As PlotEngine = PlotFactory.CreatePublishEngine()<br />
Dim acPlProgDlg As PlotProgress<strong>Dia</strong>log = New PlotProgress<strong>Dia</strong>log(False, 1, True)<br />
Using (acPlProgDlg)<br />
acPlProgDlg.PlotMsgString(PlotMessageIndex.<strong>Dia</strong>logTitle) = "Plot Progress"<br />
acPlProgDlg.PlotMsgString(PlotMessageIndex.CancelJobButtonMessage) = "Cancel Job"<br />
acPlProgDlg.PlotMsgString(PlotMessageIndex.CancelSheetButtonMessage) = "Cancel Sheet"<br />
acPlProgDlg.PlotMsgString(PlotMessageIndex.SheetSetProgressCaption) = "Sheet Set Progress"<br />
acPlProgDlg.PlotMsgString(PlotMessageIndex.SheetProgressCaption) = "Sheet Progress"<br />
acPlProgDlg.LowerPlotProgressRange = 0<br />
acPlProgDlg.UpperPlotProgressRange = 100<br />
acPlProgDlg.PlotProgressPos = 0<br />
acPlProgDlg.OnBeginPlot()<br />
acPlProgDlg.IsVisible = True<br />
acPlEng.BeginPlot(acPlProgDlg, Nothing)<br />
Try<br />
FolderBrowser<strong>Dia</strong>log1.Description = " Kies waar wilt u het bestand bewaren "<br />
If FolderBrowser<strong>Dia</strong>log1.Show<strong>Dia</strong>log = <strong>Dia</strong>logResult.OK Then<br />
selectedFolder = FolderBrowser<strong>Dia</strong>log1.SelectedPath<br />
acPlEng.BeginDocument(acPlInfo, acDoc.Name, Nothing, 1, True, _<br />
selectedFolder & "\" & Dname & " _ " & Lname & "EnergieDakProject")<br />
End If<br />
acPlProgDlg.PlotMsgString(PlotMessageIndex.Status) = "Plotting: " & acDoc.Name & _<br />
" - " & acLayout.LayoutName<br />
acPlProgDlg.OnBeginSheet()<br />
acPlProgDlg.LowerSheetProgressRange = 0<br />
acPlProgDlg.UpperSheetProgressRange = 100<br />
acPlProgDlg.SheetProgressPos = 0<br />
Dim acPlPageInfo As PlotPageInfo = New PlotPageInfo()<br />
acPlEng.BeginPage(acPlPageInfo, acPlInfo, True, Nothing)<br />
acPlEng.BeginGenerateGraphics(Nothing)<br />
acPlEng.EndGenerateGraphics(Nothing)<br />
acPlEng.EndPage(Nothing)<br />
acPlProgDlg.SheetProgressPos = 100<br />
acPlProgDlg.OnEndSheet()<br />
acPlEng.EndDocument(Nothing)<br />
acPlProgDlg.PlotProgressPos = 100<br />
acPlProgDlg.OnEndPlot()<br />
acPlEng.EndPlot(Nothing)<br />
Catch ex As Exception<br />
End Try<br />
End Using<br />
End Using<br />
End If<br />
End Using<br />
End Using<br />
16/12/2010 ED<strong>CAD</strong>1.0 HBO-Traject 2010 58
Kader Invullen<br />
Update en onthoud<br />
I will not talk about update because its work in the same way in the previous routine, just about<br />
remember "onhoud".<br />
The routine will remember nothing what going on is in the event of Form1_Load I but this<br />
routine<br />
For Each id In col<br />
Dim blokreferentie As BlockReference<br />
blokreferentie = transactie.GetObject(id, OpenMode.ForWrite)<br />
Dim AttRefIdColl = blokreferentie.AttributeCollection<br />
For Each attRefId As ObjectId In AttRefIdColl<br />
Dim AttRef As AttributeReference<br />
AttRef = transactie.GetObject(attRefId, OpenMode.ForWrite)<br />
'PROJECTNAME<br />
If AttRef.Tag.Equals(PROJECTNAME, StringComparison.OrdinalIgnoreCase) = True Then<br />
Dim PNAME As String<br />
PNAME = AttRef.TextString<br />
TextBox1.BackColor = Drawing.Color.LightGray<br />
TextBox1.Text = PNAME<br />
End If<br />
'CLIENT<br />
If AttRef.Tag.Equals(CLIENT, StringComparison.OrdinalIgnoreCase) = True Then<br />
Dim cNAME As String<br />
cNAME = AttRef.TextString<br />
TextBox2.BackColor = Drawing.Color.LightGray<br />
TextBox2.Text = cNAME<br />
And for each TextBox<br />
PrivateSubTextBox1_TextChanged(ByValsender As System.Object,<br />
ByVal e As System.EventArgs) Handles TextBox1.TextChanged<br />
TextBox1.BackColor = Drawing.Color.Empty<br />
End Sub<br />
16/12/2010 ED<strong>CAD</strong>1.0 HBO-Traject 2010 59
Attachments<br />
The first drawing is an example of situation before which took about 60 hours,<br />
the second designed by ED<strong>CAD</strong> in about 1 hour.<br />
Afterword<br />
This is just an example of Auto<strong>CAD</strong> Customization and there is plenty more to do and to learn,<br />
I wish that I have succeeded in clarifying the project.<br />
it is the end of the report and the beginning to me to find a job in this field and continue the way<br />
with autodesk deeply.<br />
now I am busy in preparing my web site ( autocadsolution.nl ), in future you may find more<br />
projects.<br />
Thank you.<br />
Athier Alwekil.<br />
16/12/2010 ED<strong>CAD</strong>1.0 HBO-Traject 2010 60