81
MainForm.bmp
Part2 Control AutoCAD on Visual Basic
Text
Chapter7 Text control…Control creating ad editing of text from VB.
Chapter8 Text insert…Import Text from Excel spread sheets.
Chapter9 Balloon…Draw balloon for architectural and mechanical use parametri-
cally.
Set up for drawings
Chapter10 Set up for drawings…Set up drawing details for AutoCAD LT on VB.
Chapter11 Layer conversion …Convert and standardize the layer.
Chapter12 VoloView…Zoom and rotate drawings for the thumbnail display.
Parametric drawings
Chapter13 Symbols (architectural use)…Draw parts for architectural use para-
metrically.
Chapter14 Symbols (mechanical use)…Draw parts for mechanical use parametri-
cally.
Chapter15 Symbols (constructional use)… Draw parts for constructional use
parametrically.
8382
t x t _ N o1-01.
t x t _ N o1-17.
t x t _ N o1-18.
t x t _ N o1-19.
MainForm.bmp
Chapter7 Change the size of text and input new data (3 kinds)
Aim…Control entering and editing. (Size and contents) text
on VB
Tip
Case1 The size of text (Change the size of the character)
Operation1…Switch the tab to <text size> of the text dialogue.
Type in <140> for [new text size] and press [Apply].
2.AutoCAD LT drawing : Open Text1.dwg . (Stored in the txt folder)
AutoCAD LT should be already started.
1.VB program: Open the text file. (Txt1.exe)
Operation2…The window switches to the AutoCAD LT to display [property copy]
command.
Click text in 3 circles.
8584
txt_No2-1.bmp
txt_No1-21.bmp
txt_No1-22.bmp
txt_No1-23.bmp
txt_No1-24.bmp
MainForm.bmp
Tip
Enter new text
① VB program : Start text file (Txt1.exe) and switch to [text insert] tab.
Operation1…Type in <living room> for [new text] in the [text insert] tab, and
<140> for [text size]
② AutoCAD LT drawing : Open Txt2.dwg. (Txt1.dwg is stored in the text
folder)
AutoCAD LT drawing file should be already started.
Input [Living room] in the red circle of the drawing. (text height 140)
Operation2…The window switches to the AutoCAD LT to display <living room> in
the drawing. Click to indicate the text location.
8786
txt_No3-1.bmp
txt_No1-24.bmp
txt_No3-12.bmp
txt_No3-14.bmp
txt_No3-11.bmp
MainForm.bmp
txt_No3-13.bmp
Tip
Edit the text
1. VB program : Start text file (Txt1.exe) and switch to [Change text] tab.
Operation2…The window switches to the AutoCAD LT, then point <dining kitchen>
and right click to confirm.
2. AutoCAD LT drawing : Open Txt3.dwg. (Txt1.dwg is stored in the txt fold-
er)
AutoCAD LT drawing file should be already started.
Change the text in a red circle to <DK> (drawing kitchen). (Text
height 140)
Operation1…Press [Choose text to change] in the <Change text> tab.
Operation3…Switch to the VB window, type in <DK> for [new text] and <140> for
[text size], then press [Apply].
Operation4…the window switches to AutoCAD LT to display the change of
the text
8988
standard_
standard_
standard tool
txt_No2-01.bmp
txt_No3-01.bmp
t x t _ N o1-01.
frm_New.bmpf r m _ N e w2.
Procedure Visual BasicApply3 tabs for [text] form.
Create new form
Choose standard EXE from [new text] tab and press [OPEN].
[Form1],new text file,was made.
Tab case1
Change text height (size) AutoCAD LT
command…MATCHPROP
Tab case2
Enter new text.
AutoCAD LT command…TEXT,MOVE
Tab case3
Change the contents and the height
of the text.
AutoCAD LT command…CHANGE
In this chapter, along with the standard control of VB control, use [tab dia-
logue control] which is included in standard tools.
To add this control, Press [Project] → [Component] and choose <Microsoft
Tabbed Dialog Control 6.0> in [Control]tab, then press [Apply].
9190
t x t _ N o1-00. txt_No1-000.bmp
txt_No1-2.bmp
txt_No1-4.bmp
txt_No1-5.bmp
t x t _ N o1-06.Change the caption for [Tab 0]
txt_No1-5-2.bmp
t x t _ N o1-05-3.
t x t _ N o1-05-5.
Change the caption for[Tab 1]
③ Chenge the caption in the prorerty of [Form 1] to <Text>
Paste tab control
1.Choose [Tab control] to create control in the Form1. (Object name <SSTab1>)
Change the caption for [Tab1]
Change the caption for [Tab2]
Change the caption in the property of [Form1] to <Text>.
2.Change captions in the property for [Tab 0] to [Tab 2].
Change the caption for[Tab 2]
9392
t x t _ N o1-03.
t x t _ N o1-07.t x t _ N o1-08.
t x t _ N o1-09.
Standard_Tab2
①
①
Create the button to close this form
1. Choose <Command Button> from [Standard control]
3. Double click [End] button to describe the procedure when this button is
pressed.
2.Type in the caption <END> to Command1] and change (object name) to
<frm_End>.
Code Summary
Unload Me ・・・ Close own form (Form1)
9594
t x t _ N o1-10.
t x t _ N o1-11. t x t _ N o1-12.
t x t _ N o1-13. t x t _ N o1-14.
t x t _ N o1-15.
① ②
③
① -1① -2②
③
① -2(Label2)① -1(Label1)
③ (cmd_Ok)② (Text1)
Case1 Create controls for [text size] tab and program.
[Step4] Create control
3.Apply a <Command Button> control from [Standard control].
(Object name) for Command2 → cmd_Ok1
A caption for Command2 → [Apply]
Standard-Tab2
2.Apply a <Text Box> control from [Standard control].
1.Apply two <Label> controls from [Standard control].
A caption for <Label1> → new text size
A caption for <Label2> → mm
Standard-Tab2
9796
t x t _ N o1-16.
・・・ Open the file in INPUT/OUTPUT mode.Print #1, “TEXT” &”0,0” & txt_S & “ 0” & “ 1” & Chr(13) ・・・ Write out the contents of the script. (Summary No.1).Print #1, “matchprop “ & “L” ・・・ [matchprop] of AutoCAD LT copies the property of the selected object to another object.Close #1 ・・・ Close the file.AppActivate “AutoCAD” ・・・ Activate AutoCAD LT.Sendleys “filedia 0” & Chr(13) & “svript” & Chr(13) & Sname & Chr(13)_ & “filedia 1” & Chr(13),True ・・・ Send the script file to the AutoCAD LT command line.
[Step5] Program
1.Double click [APPLY] to program the code below.
Summary No.1 [Space between ・ ・functions as Return Key]
“EXT“ & “0,0”& txt_S & “0” & “1” & Cha(13)
“EXT” ・・・ AutoCADLT command [create a line text]
“0,0” ・・・ The axis value for the text insertion point
txt_S ・・・ Text size
“0” ・・・ Text writing direction
“1” ・・・ Text contents [type in 1]
Cha(13) ・・・ Return
*Type in any letter to define the text size, then delete that letter later.
Chain the code above with ・・to create a script file.
Private Sub cmd_0k1_Click
Dim Sname As String ・・・The text column states the unstable number.
Dim txt_V As String
・・・ The text column states the unstable number.
Dim txt_S As integer
・・・ The integral number states the unstable number.
txt_V=Text1.Text
・・・ Relocate the contents of [Text box-Text1]
to <txt-V>
txt_S=Clmt(txt_V)
・・・ Convert text date in txt_V into numeric value.
Sname= 任 :\LT2VB\text\text.scr・
・・・ Convert text date in txt_V into numeric value.
Open Sname For Outpit As #1
btm_apply.bmp
9998
txt_No2-10.bmp
btm_Insert.t x t _ N o2-02.
t x t _ N o2-03. t x t _ N o2-04.
t x t _ N o2-05. t x t _ N o2-06.t x t _ N o2-07.
t x t _ N o2-08.
t x t _ N o2-09.
Case Ⅱ・・・Crate controls for [text insert] tab, then program.
[Step6]・・・Create controls.
① Apply three <Label> controls from [Standard control]
・A caption for <Label 1> -> new text.
・A caption for <Label 2> ->text size.
・A caption for <Label 3> -> mm.
② Apply two <Text Box> controls from [Standard control]
・Text for Text2 -> Blank
・Text for Text -> Blank
③ Apply a <CommandButton>controls from [Standard control]
・(Object name) for Command2 -> cmd_Ok2
・A caption for Command2 -> [Insert.]
① ②
③① -1 ② -1
① -2 ② -2 ① -3
③
① -2(Label4)① -1(Label3)
② -1(Txet2) ③ (cmd_Ok2)
① -3(Label5)
② -2(Txet3)
Program
Double click [ ] to program the code below.
Standard-Tab2
101100
Dim Sname As String
“TEXT” & “0,0” & txt_S & “0” & txt_N & Chr(13)
“TEXT ・・・ AutoCAD LT command [create a line text]
”0,0” ・・・ The axis value for the text inserting point
txt_S ・・・ Text size
” 0” ・・・ Text writing direction
txt_N ・・・ Text contents
Chr(13) ・・・ Return
Chain the code above with ・・to create a script file
Private Sub cmd_0k2_Click()
・・・The text column states the unstable number.
Dim txt_N As String
・・・The text column states the unstable number.
Dim txt_V As Srting
・・・The text column states the unstable number.
Dim txt_S As integer
・・・The integral number states the unstable number.
txt_N = Text2.Text
・・・Relocate the contents of [Text box ・Text 2] to <txt_N>.
txt_V = Text3. Text
・・・Relocate the contents of [Text box ・Text 3] to <txt_V].
txt_S = Clnt(txt_V)
・・・Convert text date in txt_V into numeric value.
Sname = “C:/LT2VB/text/text.scr・
・・・Create the script file by MEMO first.
Open Sname For Output As #1
・・・Open the file in INPUT/OUTPUT mode.
Print #1, ”TEXT”& “0,0” & txt_S & “0” & txt_N & Chr(13)
・・・Write out the contents of the script. (Summary No.2)
Print #1, “MOVE L”0.0”
・・・Relocate the text from original point. (The destination
can be chosen)
Close #1
・・・Close the file.
AppActivate AutoCAD・
・・・Activate AutoCAD LT.
SendKeys “filedia 0” & Chr(13) & “script” & Chr(13) & Sname & Chr(13)
& ”filedia 1 “ & Chr(13), True
・・・Send the script file to the AutoCAD LT command line.
End Sub
Summary No.2 [Space between “ “ functions as Return Key]
103102
t x t _ N o3-10.
btm_Choose.
t x t _ N o3-02.
t x t _ N o3-03.
t x t _ N o3-04. t x t _ N o3-05. t x t _ N o3-06.
t x t _ N o3-07. t x t _ N o3-08.
t x t _ N o3-09.
① ②
③
① -2(Label7)① -1(Label6)
③ -1(cmd_Sen)
② -1(Text4)
② -2(Text5) ③ -2(cmd_Ok3)
[Case3] Create controls for [text insert] tab, then program.
Program
1.Double click [Choose text to change] to program the code below.
Choose
[Step8] Create Controls
1.Apply two <Label> controls from.
・ A caption for Label6 → new text
・ A caption for Label7 → new size
2.Apply two <Text Box> controls from [Standard Control]
・ Text for Text4 → Blank
・ Text for Text5 → Blank
3.Apply two <Command Button> controls from [standard control].
・ (Object name) for Command4
・ A caption for Command4 → Choose text to change
・ (Object name) for Command5
・ A caption for Command5 → [APPLY]
・ Standard-Tab2
Standard-Tab2
105104
btm_Apply.bmp
txt_No3-45.bmp
2.Double click [APPLY] to program the code below.
“CHANGE” & “P” & Chr(13) & Chr(13) & Chr(13)_
& txt_S & “0” & txt_N
“CHANGE” ・・・ AutoCAD LT command [Edit drawing command]
”P” ・・・ Previously selected drawing (text in this example)
txt_S ・・・ Text size
”0” ・・・ Text writing direction
txt_N ・・・ Text contents
Chr(13) ・・・ Return
Chain the code above with ”&”to create a script file.
Change command asks the procedure as below in [Text EDITING].
<choose object> <point changing> location or [property (P):> <indicate new lo-
cation for text insert <do not change>:> <insert new text style <standard>:>
<indicate new height> <indicate new angle> <Enter new text>
Private Sub cmd_0k3_Click()
Dim Sname As String
・・・ The text column states the unstable number.
Dim txt_N As String
・・・ The text column states the unstable number.
Dim txt_V As String
・・・ The text column states the unstable number.
Dim txt_S As integer
・・・ The integral number states the unstable number.
txt_N = Text4.Text
・・・ Relocate the contents of [Text box ・Text4] to <txt_N>.
txt_V = Text5.Text
・・・ Relocate the contents of [Text box-Text5] to <txt_V>.
txt_S = Clnt(txt_V)
・・・ Convert text date in txt_V into numeric value.
Sname = “C:/LT2VB/text/text.scr
・・・ Create the script file by MEMO frst.
Open Sname For Output As #1
・・・Open the file INPUT/OUTPUT mode.
Print #1 “CHANGE” & “P” & Chr(13) & Chr(13) & Chr(13) & Che(13)_
& txt_S & “0” & txt_N
・・・ Write out the contents of the script (Summary No.3).
Close #1
・・・Close the file.
AppActivate “AutoCAD”
・・・ Activate AutoCAD LT.
SendKeys “filedia 0” & Chr(13) & “script” & Chr(13) & Sname & Chr(13)_
& “filedia 1” & Chr(13), True
・・・ Send the script file to the AutoCAD LT command line.
End Sub
Summary No.3 [Space between ・ ・functions as Return Key]
107106
t x t _ N o4-01.
t x t _ N o4-02.
t x t _ N o4-03.t x t _ N o4-04.
t x t _ N o4-06.
[Step10] Save programs
1.Title and save the form of this program.
Choose [File] → [Title and save Form1]
(In this example, the program is titled <text1> and saved in VB98 folder.)
3.Finally, create exe file.
Choose [File] → [Create Project.exe]
(In this example, the file is titled <txt1> and saved in VB98 folder.)
2.Title and save the Project of this program.
Choose [File] → [Title and save project]
(In this example, the program is titled <txt1> and saved in VB98 folder.)
txt_No4-05.bmp
109108
t x t _ N o5-22.
t x t _ N o5-23.
t x t _ N o5-21.
t x t _ N o5-01.
MainForm.bmp
Chapter8 Text insert (Import from Excel)
Aim…Import text registered on Excel spread sheets into AutoCAD LT.
Tip
① VB program : Start text file (Txt4.exe)
Operation1…Type in <300> for <Text size> and choose <Living room> from the
cells, then press [Insert].
② AutoCAD LT drawing : Open Txt4.dwg.
Insert <Living room> in the circle below.
Operation2…The window switches to AutoCAD LT to display <Living room> in the
drawing. Click to indicate the text location.
111110
t x t _ N o5-05.
t x t _ N o5-06.
t x t _ N o5-02.S t a n d a r d t x t _ N o5-03.
frm_New.bmpf r m _ N e w2.
t x t _ N o5-03.
t x t _ N o5-08.
C:\LT2VB\text\ 建築用語 .xls
[Step1] ・・・ Create a new form
1.Choose Standard EXE from [NEW] tab, and press [OPEN].
[Form1], new text file, is made.
[Step2] ・・・ Paste Data Control1. Choose [Data Control] to create control in the Form1. (Object name <Data1>)
In this program, along with the standard control of VB control, use [Date
Bound Grid Control] which is not a standard tool.
To add this control, Press [Project] → [Component] and choose <Microsoft Data
Bound Grid Control> in [Control] tab, then press [APPLY].
Standard tool
② Link [Date control] to Excel text list. (Indicate sheet name to link.)
③ Change property of [Data control] (Object name <Data1>)
・Caption → Architectural term
・Connect → Excel8.0
・DatabaseName → Architectural term.xls
・Recordsource → Sheet1$
113112
t x t _ N o5-10.t x t _ N o5-11.
txt_No5-13.bmp
t x t _ N o5-12.
t x t _ N o5-07. t x t _ N o5-09.
t x t _ N o5-03.
①
②
③
④
① ② ③ ④ -1 ④ -2DBGrid1 の DataSource の指定
txt_No5-12-2.bmp
[Step3] ・・・Paste Date Bound Grid Control
① Choose [Date Bound Grid Control] to create control in the Form1.
(Object name <DBGrid1>) → Data1
Create Controls
① Apply a <Label> control of [Standard control].
A caption for Label1 → Text size
② Apply a <Combo Box> control from [Standard control].
Text for Combo1 → Blank
③ Apply a <Text Box> control from [Standard control].
Text for Text1 → Blank
④ Apply two <Command Button> controls from [Standard control]
・(Object name) for Command1 → frm_Ok
・A caption for Command1 → Insert
・(Object name) for Command2 → frm_End
・A caption for Command2 → End
Standard-Tab2
Data1 Reserve Connect Data1 Reserve Datasename Data1 Reserve RecordSource
115114
t x t _ N o5-19.
t x t _ N o5-15. t x t _ N o5-16.
t x t _ N o5-17. t x t _ N o5-18.
t x t _ N o5-14.
① (Label1) ② (Combo1) ③ (Text1)
④ -1(CommandButton1) ④ -2(CommandButton2)
[Step5] ・・・Program
Double click [Insert] to program the code below.
117116
t x t _ N o5-20.
2.Double click [End] to program the code below.
"text " & "0,0 " & Txt_I & " 0 " & Txt_v & Chr(13)
“TEXT ” ・・・AutoCAD LT command [create a line text]
“0,0 ” ・・・ The axis value for the text insertion point
txt_l ・・・Text size
“ 0” ・・・Text writing direction
Txt_V ・・・Text contents [write1]
Chr(13) ・・・Return
Chain the code above with “&” to create a script file.
[Step6]・・・ Save the program
1.Title and save the form of this program.
Choose [File] → [Title and save Form1] ・・・frm_Txt4.frm
2.Title and save the project of this program.
Choose [File] → [Title and save project1] ・・・Txt4.vbp
3.Finally, create exe file.
Choose [File] → [Project1.exe] ・・・Txt4.exe
Private Sub cmd_0k_Click()
Dim Txt_v As String
・・・The text column states unstable number.
Dim Sname As String
・・・The text column states unstable number.
Dim Txt_L As Sting
・・・The text column states unstable number.
Dim Txt_l As lnteger
・・・The text column states unstable number.
Sname = “C:/LT2VB/text/text.scr”
・・・Create the script file by MEMO first.
Text1.Text = DBGrid1.SelText
・・・Set the contents of active cell of [DBGrid1] into [Text Box-Text1].
Txt_v = Text1. Text
・・・Relocate the contents of [Text Box-1] to <txt_V>.
Txt_L = Combo1. Text
・・・Relocate the contents of [Combo Box-Combo1] to <txt_L>
Txt_l = Clnt(Txt_L)
・・・Convert text data in txt_V into numeric value.
Open Sname For output As #1
・・・Open the file in INPUT/OUTPUT mode.
Print #1 , “text” & “0,0” & Txt_l & “0” & Txt_v
・・・Write out the contents of the script (Summary No.4).
Print #1 , “zoom a”
・・・Display the overall view of the drawing by [ZOOM].
Print #1 , “filedia 1”
Print #1 ,move l 0,0”
・・・Relocate the text from original point (the destination can be
picked.)
Close #1
AppActivate “AutoCAD”
・・・Activate AutoCAD
Sendokeys “filedia 0” & Chr(13) & “script” & Chr(13) & Sname &
Chr(13) ,True
・・・Send the script file to the AutoCADLT command line.
End Sub
Summary No.4 [Space between ・ ・functions as Return Key]
Unload Me・・・Close this form.
119118
b a l _1-02-1.
b a l _1-02-2.
MainForm.bmp
bal_00.bmp
bal_1-02.bmp bal_1-03.bmp
Case Ⅰ Case Ⅱ
Chapter9 Create Balloons(2kinds)
Aim…Create balloons for architectural and mechanical use to insert
AutoCAD LT.
Case1 Architectural balloon
② AutoCAD LT drawing : Open balloon1.dwg.(This file is stored under the direc-
tory of balloon.)
Insert balloons in the grids as below.Tip
① VB program : Open balloon file (ballon.exe).
Mechanical balloons.
② AutoCAD LT drawing : Open balloon2.dwg.(This file is stored under the direc-
tory of balloon.)
Insert balloons as below.
121120
P
b a l _1-02-3.
P
Case1
Operation ①…Type in <X> for [text type], <1> for [number] and <500> for
[balloon size].
Press the balloon below.
Case2
Operation ①…Type in <1> for [number], <10> for [balloon size] and <30> for
<line length>.
Press left balloon.
Operation ②…The window switches to AutoCAD LT.
Crick the grids (point P) to insert balloons.Operation ②…The window switches to AutoCAD LT. Click the point (point P) in
the right half of the drawing.
123122
frm_New.bmpf r m _ N e w2.
bal_1-01.bmp
MainForm ・・・frm_bal-
bal_1-11.bmp bal_2-01.bmp
SubForm ・・・frm_bal- SubForm ・・・frm_bal-
Produce on Visual BasicAdd 2 forms to the main form, [balloon].
(Architectural use balloon is A and Mechanical use balloon is B)
[Step2] Create Controls.
① Apply two <Label> controls from [Standard control].
・A caption for Label1 → Architectural
・A caption for Label2 → Mechanical
[Step1] Create new form
① Choose standard EXE from [new text] tab and press [OPEN], [Form1], new text
file, is made.
② Change caption in the property of form1 to <balloon>.
② Apply three. <Command Button> controls from [Standard control]
・(object name) for Command1 → balloonA
・A caption for command1 → Blank
・Picture for Command1 → (bitmap)
・Style for Command1 → 1-graphics
・(object name) for command2 → balloonB
・A caption for command2 → Blank
・Picture for command2 → (bitmap)
・Style for Command2 → 1-graphics
・(object name) for command3 → frm_end
・A caption for Command3 → End
125124
bal_1-08.bmp
bal_1-09.bmp
bal_1-06.bmp
bal_1-07.bmp
③ -1(CommandButton1)
③ -2(CommandButton2)bal_1-01.bmp
①
②
① -1
② -1
① -2
② -2
② -3
b a l _1-02-7.
bal_1-04.bmp bal_1-05.bmp
① -1(Label1) ① -2(Label2)
4.A caption for balloonA is blank and choose down.bmp for a picture.
Do not forget to pick <1-graphics> for style to display the picture.
(down.bmp is stored in the folder.)
5.A caption for balloonB is blank and choose arrow-1.bmp for picture.
Do not forget to pick <1-graphics> for style to display the picture.
(arrow-1.bmp is stored in the folder.)
Standard-Tab2
127126
bal_1-11.bmp
① -1
①
②
③
① -2
① -3
① -4
② -1
② -2
② -3
③ -1
③ -2 ③ -3
③ -4③ -5
bal_1-10.bmp
bal_1-11.bmp
b a l _1-02-8.
b a l _1-02-9.
bal_1-02-10.bmp
bal_1-02-11.bmp
[Step3] Program
1.Describe the move when [balloonA] is clicked.
① Apply four <Label>controls from [Standard control].
・A caption for Label1 → text type
・A caption for Label2 → number
・A caption for Label3 → circle size
・A caption for Label4 → number from
② Apply three <ComboBox> controls from [Standard control].
・Text for Combo1 → Blank
・List for Combo1 → Type in value from keyboard. (Refer to the picturebelow.)
・Text for Combo2 → Blank
・List for Combo2 → Type in value from keyboard. (Refer to the picturebelow.)
・Text for Combo3 → Blank
・List for Combo3 → Type in value from keyboard. (Refer to the picturebelow.)
3.Describe the move when [End] is clicked.
2.Describe the move when [baloonB] is clicked.
Case1 Create controls for [frm_baloonA], then program
[Step4] Create Controls
frm_balloonA.show ・・・ Display (frm_BalloonA)
Unload Me ・・・ Close (frm_Balloon)
frm_balloonB.Show ・・・ Display (frm-baloonB)
Unload Me ・・・ Close (frm-Baloon)
Close (frm_baloon)
Standard-Tab2
129128
bal_1-15.bmp
bal_1-16.bmp
③ -1(CommandButton-Up)
bal_1-02-16.bmp
bal_1-02-17.bmp
bal_1-02-18.bmp
bal_1-02-19.bmp
③-2(CommandButton-Right)
③ -3(CommandButton-Left)
bal_1-12.bmpbal_1-13.bmp bal_1-14.bmp
② -1(Combo1) ② -2(Combo2) ② -3(Combo3)
① -1(Label1)
bal_1-02-12.bmp
① -2(Label2)
bal_1-02-13.bmp
① -3(Label3)
bal_1-02-14.bmp
① -4(Label4)
bal_1-02-15.bmp
3.Apply 5 <Command Button> controls from [Standard control]
・(Object name) for Command button1 → Up
・A picture for Command button1 → (bitmap)…balloon folder
・A style for Command button1 → 1-graphics
・(Object name) for Command button2 → Right
・A picture for Command button2 → (bitmap)…balloon folder
・A style for Command button2 → 1-graphics
・(Object name) for Command button3 → Left
・A picture for Command button3 → (bitmap)…balloon folder
・A style for Command button3 → 1-graphics
・(Object name) for Command button4 → Down
・A picture for Command button4 → (bitmap)…balloon folder
・A style for Command button4 → 1-graphics
・(Object name) for Command button5 → End
・A caption for Command button5 → End
131130
bal_1-17.bmp
bal_1-02-20.bmp
bal_1-02-21.bmp
③ -4(CommandButton-Down)
bal_1-02-22.bmp
③ -5(End)
bal_1-02-35.bmp
[Step5]・・・Program
① Double click [Up] to program the code below.
Private Sub Up_Click()
Dim Sname As String
・・・The text column states the unstable number.
Dim txt_T As String
・・・The text column states the unstable number.
Dim txt_B As String
・・・The text column states the unstable number.
Dim txt_E As String
・・・The text column states the unstable number.
Dim en_C As integer
・・・The integral number states the unstable number.
Diam en_H As integer
・・・The integral number states the unstable number. txt_T =Combo1.Text
・・・Relocate the contents of [ComboBox _ombo1] to <txt_T>.
txt_B = Combo2.Text
・・・Relocate the contents of [ComboBox _ombo2] to <txt_B>.
txt_E = Combo3.Text
・・・Relocate the contents of [ComboBox _ombo3] to <txt_E>.
en_C = Clnt(txt_E)
・・・Convert text data in txt_E into numeric value.
en_H = en_C / 2
・・・To calculate the radius of the circle to divide diameter by 2.
Sname = "C:/LT2VB/balloon/balloon.scr"
・・・Create the script file by MEMO first.
Open Sname For Output As #1
・・・Open the file in INPUT/OUTPUT mode.
Print #1, "Circle " & "0,0 " & en_H
・・・Circle command (the center point axis <0,0>, the radius is
<en_H>)
Print #1, "select L "
Print #1, "line " & "0" & "," & "-" & en_H & Chr(13) _
& "0" & "," & "-" & en_C & Chr(13)
・・・Line Command (Summary No.1)
133132
bal_1-21.bmp
bal_1-02-10.bmp
0,0
0,-en_H
0,-en_C
2.Repeat the steps create commands for other 3 buttons.
3.Double click [End] to program the code below.
Summary No.1 [Space between ” ”functions as Return key.
"line " & "0" & "," & "-" & en_H & Chr(13) & "0" & "," & "-" & en_C &
Chr(13)
“LINE ” ・・・ AutoCAD LT command [Draw lines]
0,-en_H ・・・ Axis of starting point
0,-en_C ・・・ Axis of the end point
Chr(13) ・・・ Return
Chain the code above with “&”to create a script file.
Summary No.2 [Space between “ “functions as Return key]
"text " & "j " & "Mid " & "0,0 " & en_H & " 0 " & txt_T & txt_B
“TEXT ” ・・・ AutoCAD LT command [create a line text]
“j “ ・・・ Option for aligning text (M to align in center)
“0,0 ” ・・・ The axis value for the text inserting point
en_H ・・・ Text size
“ 0” ・・・ Text writing direction
txt_T&txt_B ・・・ Text contents
Chr(13) ・・・ Return
Chain the code above with “ “ to create a script file.
Unload Me ・・・ Close the form.
Print #1, "select L P "
Print #1, "text " & "j " & "Mid " & "0,0 " & en_H & " 0 " & txt_T & txt_B
・・・Text Command (Summery No.2)
Print #1, "select L P "
Print #1, "move L P " & "0,-" & en_C
・・・Move command (the initial point is in the lower tip of the line,
the destination can be picked)
Close #1
AppActivate "AutoCAD"
・・・ Activate AutoCAD LT.
SendKeys "filedia 0" & Chr(13) & "script" & Chr(13) & Sname & Chr(13) _(13)_
& "filedia 1" & Chr(13), True
・・・Send the script file to the AutoCAD LT command line.
135134
bal_2-02.bmpbal_2-03.bmp bal_2-04.bmp
① -1(Label1) ① -2(Label2) ① -3(Label3) ① -4(Label4)
bal_1-02-23.bmp bal_1-02-24.bmp bal_1-02-27.bmp bal_1-02-26.bmp
② -1(Combo1) ② -2(Combo2) ② -3(Combo3)
bal_2-01.bmp2Standard-Tab2
① -1
①
②
③
① -2
① -3
① -4② -1
② -2
② -3
③ -1③ -2
③ -3 ③ -4
③ -5
1.Apply 4 <Label1> controls from [Standard control].
・A caption for Label1 → number
・A caption for Label2 → the size of circles
・A caption for Label3 → length of lines
・A caption for Label4 → number from
2.Apply 3 <ComboBox> controls from [Standard control].
・Text for Combo1 → Blank
・List for Combo1 → Type in value from keyboard. (Refer to the picture below)
・Text for Combo2 → Blank
・ List for Combo2 → Type in value from keyboard. (Refer to the picture
below)
・Text for Combo3 → Blank
・List for Combo3 → Type in value from keyboard. (Refer to the picture below)
③ Apply 5<CommandButtom> controls from [standard control]
・ (The object name) for CommandButton1 -> right_up
・ The picture for CommandButton1(bitmap) ・・・ balloon folder
・ The style for CommandButton1 -> 1-graphics
・ (The object name) for CommandButton2
・ The caption for CommandButton2 -> (bitmap) ・・・ balloon folder
・ The style for CommandButton2 -> 1-graphics
・ (The object name) for CommandButton3
・ The caption for CommandButton3 -> (bitmap) ・・・ balloon folder
・ The style for CommandButton3 -> 1-graphics
・ (The object name) for CommandButton4
・ The caption for CommandButton4 -> (bitmap) ・・・ balloon folder
・ The style for CommandButton4 -> 1-graphics
・ (The object name) for CommandButton5
・ The caption for CommandButton5 -> [End]
Case2 Create controls for [frm-balloonB], then program.
[Step6] Create Controls
137136
bal_2-07.bmp
bal_1-02-32.bmp
bal_1-02-33.bmp
③ -4(left_Down)
bal_1-02-34.bmp
bal_1-02-35.bmp
③ -5(End)
bal_2-05.bmp
bal_2-06.bmp
③ -1(right_Up)
bal_1-02-28.bmp
bal_1-02-29.bmp
③ -2(left_Up)
bal_1-02-30.bmp
bal_1-02-31.bmp
③ -3(left_Down)
1.Double click [right up] to program the code below.
Program
139138
sen/1.414sen
sen/1.414
.
"line " & "0,0 " & LTrim(Str(sen / 1.414)) & "," & LTrim(Str(sen / 1.414)) &
Chr(13)
“LINE” ・・・ AutoCAD LT command [Draw lines]
”0,0” ・・・ Axis value of the starting point of the line.
LTrim(Str(sen/1.414)) ① calculate the increase of X value,then convert
into the text column.
② Delete space left of the text column.
LTrim(Str(sen/1.414)) ③ Calculate the increase of Y value,then convert
into the text column.
Erase the left space of text column.
Chr(13) ・・・ Return
Chain the code above wuth “&”to create script file.
Private Sub right_Up_Click()
Dim Sname As String
・・・The text column states the unstable number
Dim txt_T As String
・・・The text column states the unstable number
Dim txt_C As String
・・・The text column states the unstable number
Dim txt_S As String
・・・The text column states the unstable number
Dim en_C As Integer
・・・The integral number stakes the unstable number
Dim en_H As Integer
・・・The integral number stakes the unstable number
Dim sen As Integer
・・・The integral number stakes the unstable number
txt_T = Combo1.Text
・・・Relocate the contents of [ComboBox_Combo1] to <txt_T>
txt_C = Combo2.Text
・・・Relocate the contents of [ComboBox_Combo2] to <txt_G>
txt_S = Combo3.Text
・・・Relocate the contents of [ComboBox_Combo3] to <txt_S>
en_C = CInt(txt_C)
・・・Convert Text data in txt_G into numeric value(diameter of circle)
en_H = en_C / 2
・・・Calculate radius by dividing en_G by 2.
sen = CInt(txt_S)
・・・Convert Text data in Txt_S in numeric value.
Sname = "C:/LT2VB/balloon/balloon.scr"
・・・Create the script file by memo first.
Open Sname For Output As #1
・・・Open the file in INPUT/OUTPUT mode.
Print #1, "Donut " & "0 " & LTrim(Str(en_C / 10)) & " " & "0,0 "
・・・Donuts command (inner circumference<0>, Outer shape
<1/10 of the circle>
Print #1, "select L "
Print #1, "line " & "0,0 " & LTrim(Str(sen / 1.414)) _
& "," & LTrim(Str(sen / 1.414)) & Chr(13)
・・・Draw a line of 45° angle using line comamnd(Summary No1.)
Print #1, "select L P "
Print #1, "Circle " & "@" & LTrim(Str(en_H / 1.414)) _
& "," & LTrim(Str(en_H / 1.414)) & " " & en_H
・・・Create circles for balloons using Circle command (Summary No.1)
Print #1, "select L P "
Print #1, "text " & "j " & "Mid " & "@0,0 " & en_H & " 0 " & txt_T
・・・Type in text to insert in balloons using text command.
Print #1, "select L P "
Print #1, "move L P " & "0,0"
・・・Move balloons by [Move] command.
Close #1
AppActivate "AutoCAD"
・・・Activate AutoCAD LT
SendKeys "filedia 0" & Chr(13) & "script" & Chr(13) & Sname & Chr(13) _
& "filedia 1" & Chr(13), True
・・・Send the script file to the AuroCAD LT command line.
End Sub
Summary No.1 [Space between “ “ function as return key.]
141140
zumen_01.bmp
z u m e n _01-2.
bal_2-11.bmp
[Step8] Save the program
① Title and save the form of this program.
Choose [file]-[Title and save Form1] ・・・ frm_balloon.frm frm_Balloon.
frm
② Title and save the project of this program.
Choose [file]-[Title and save project1] ・・・ balloon.vbp
③ Finally,create exe file
Choose [file]-[project1.exe] ・・・ balloon.exe
Chapter10 Set_Up the drawing
AIM Setup the drawing of SutoCAD LT(for page size,picture frame)
On VB window.
TIP
①VB program:Open drawing set_up(zumen.exe)
① Repeat the same steps to create commands for other 3 buttons.
② Double click [End] to program the code below.
Unload Me ・・・ Close this form.
② AutoCAD LT drawing:Open a new file,then the page will be
set_up
As the set up on VB.
(initial value of AutoCAD LT A3 <420,297>)
42000mm in the width,29700mm in the length.
Picture frame is already drawn.
143142
①
②
③① -1
② -2
③ -1
① -2② -1
③ -2
zumen_03.bmp zumen_04.bmp zumen_06.bmp
① -1(Label1) ① -2(Label2) ② -1( C o m b o -frm_New.bmp
f r m _ N e w2.
[Step2] Create controls
① Apply2 <label >controls form [standard control]
The text for Combo1 -> Page size
The text for Combo2 -> inche
② Apply2 <combobox >controls form [standard control]
The text for Combo1 -> Blank
The text for Combo2 -> Blank
③ Apply2 <commandButton> controls form [standard control]
(The object name) for Command1 -> cmd_Ok
The caption for Command1 -> Draw on AutoCAD LT
(The object name) for Command1 -> cmd_End
The caption for Command2 -> End.
Procedure on VisualBasic
[Step1] Create a new form
① Choose standard exe from [new form]
Tab and press [Open] new form [form1] is made.
② Change the caption for [Form1] to <Drawing Set_up>
Standard-Tab2
zumen_02.bmp
zumen_02-1.bmp
145144
zumen_12.bmpz u m e n _03-3.
zumen_11.bmp
zumen_09.bmp zumen_10.bmpzumen_07.bmp
② -2( C o m b o - ③ -1(CommandButton1) ③ -2(CommandButton2)
ComboBox1.Addltem “A3” ・・・ Add item A3 to the list of <ComboBox1>
ComboBox1.Addltem “A2” ・・・ Add item A2 to the list of <ComboBox1>
ComboBox1.Addltem “A1” ・・・ Add item A1 to the list of <ComboBox1>
ComboBox2.Addltem “1/200” ・・・ Add item 1/200 to the list of <ComboBox2>
ComboBox2.Addltem “1/100” ・・・ Add item 1/100 to the list of <ComboBox2>
ComboBox2.Addltem “1/50” ・・・ Add item 1/50 to the list of <ComboBox2>
ComboBox2.Addltem “1/1” ・・・ Add item 1/1 to the list of <ComboBox2>
Size = ComboBox1.Text
・・・Relocate the contents of [ComboBox1] to <size>
Syakudo = ComboBox2.Text
・・・Relocate the contents of [ComboBox2] to <angle>
if Syakudo = “”Or Size = “”Then
・・・When <angle> or <size> is blank,go to the end of
the program.
MsgBox (“Please chppse”)
Exit Sub
Ecd if
[step3] Program
① Automatically set text on the lists of [CommandBox1]
And [ComboBox2],when the [Drawing Set_up] form is loaded.
① Double click [draw on AutoCAD LT] and program the code below.
Private Sub cmd_OK_Ckick()
Dim Syaludo,Size ,Zahyo, Sname As String ・・・The text column States the unstable number.
147146
zumen_13.bmp
If the value of [angle] is <1/200> and the
value of [size] is <A3>,
Set <84000,59400> to [axis] Repeat the same
steps.
[Step4] save the program
① Title and save the form of this program..
Choose [file]-[Title and save Form1] ・・・ frm_zumen.frm
② Title and save the project of this program.
Choose [file]-[Title and save project1] ・・・ zumen.vbp
③ Finally,create exe file.
Choose [file]-[create project1.exe] ・・・ zumen.exe
Unload Me ・・・ Close this form
Select Case Syakudo
Case "1/200"
Select Case Size
Case "A3・
Zahyo = "84000,59400"
Case "A2"
Zahyo = "118800,84000"
Case "A1"
Zahyo = "168200,118800"
End Select
Case "1/100"
Select Case Size
Case "A3"
Zahyo = "42000,29700"
Case "A2"
Zahyo = "59400,42000"
Case "A1"
Zahyo = "84100,59400"
End Select
Case "1/50"
Select Case Size
Case "A3"
Zahyo = "21000,14850"
Case "A2"
Zahyo = "29700,21000"
Case "A1"
Zahyo = "42000,29700"
End Select
Case "1/1"
Select Case Size
Case "A3"
Zahyo = "420,297"
Case "A2"
Zahyo = "594,420"
Case "A1"
Zahyo = "841,594"
End Select
End Select
・・・
Sname = "C:/LT2VB/zumen/zumen.scr"
・・・Create the script file by memo first.
Open Sname For Output As #1
・・・Open the file in INPUT/OUTPUT mode
Print #1, "limits 0,0 " & Zahyo
・・・[Limits] means the picture limit.-> Bottom left value is the initial point and
the upper right one
belongs to the unstable number Zahyo value
Print #1, "rectang 0,0 " & Zahyo
・・・[rectang] means rectangle command the whole view->Bottom left value is the ini-
tial point and the
upper right one draws the rectangle.
Print #1, "zoom a"
・・・Zoom
Print #1, "filedia 1"
・・・Display the dialogue.
Close #1
AppActivate "AutoCAD"
・・・Activate AutoCAD LT
SendKeys "filedia 0" & Chr(13) & "script" & Chr(13) & Sname & Chr(13), True
・・・Send the script file to the AutoCAD LT command line.
End Sub
③ Double click [End] to program the code below.
149148
layer_01.bmp
MainForm.bmp
layer_02.bmp
layer_03.bmp
layer_04.bmp
layer_05.bmp
layer_06.bmp
Chapter11 Layer name replacement
AIM Automechanically,replace the layer names on VB
for the standardized one of constructional CALS.
TIP
① VB program:Start the layer replacement file,layer.exe.
Operation ① Choose< 家具 >of [Existing layer name] and pick <furniture> from
[Replacing layer name],then press [Replace]
② AutoCAD LT drawing:Open layer.dwg.
(Layer.dwg is stored in the layer folder)
AutoCAD LT drawing file should be alredy started.
Operation ② The window switches to the AutoCAD LT to display <Furniture>
instead of < 家具 >
"The layer" of Layer.dwg is written in Japanese.
151150
frm_New.bmpf r m _ N e w2.
① -1①
④
① -2
③②
④ -1
④ -2
③ ②
layer_07.bmp
① -1(Label1) ① -2(Label2)
layer_08.bmp layer_09.bmp layer_10.bmp
② -1(old_lay)
[Step1] Create a new form
① Choose standard.exe form [new form] tab and press{open],
[Form1],a new file,appears in the window.
② Open the property of Form1 to change the caption to<Replace the layer name>
① Apply two<Label>control of [Standard control]
The caption for label1 -> Existing layer name
The caption for label2 -> Replacing layer name.
② Apply a<List Box>control from [Standard control]
(the object name)for ListBox1 -> old_lay
(The text include in the list is automatically added to
when this form is loaded.
③ Apply a <ComboBox>control from [Standard control]
(the object name) for LIstBox1 -> new_lay
④ Apply two <command Button>controls from [standard control]
(the object name)for commandButton1 -> cmd_OK
The caption for CommandButton1 -> [repalce]
(The object name) for CommandButton2 -> cmd_End
The Caption for CommandButton2 -> [End]
{Step2] Create Controls
Standard-Tab2
153152
④ -1(new_lay) ⑤ -1(cmd_Ok)
layer_11.bmp layer_12.bmp layer_13.bmp
⑤ -2(cmd_End)
① Set the text in the list column of [ListBox1]automatically,
when the [Layer repalcement]form is loaded.
② Double click [replace] and program the code below.
[Step3] Program
Private Sub Form_Load()
with old_Lay
Addltem “ kitchen” ・・・Add[Kitchen]to the list
Addltem “ View” ・・・Add[Kitchen]to the list
Addltem “ Furniture” ・・・Add[Furniture]to the list
Addltem “ Standard kine” ・・・Add[Standard line]to the list
Addltem “ Floor” ・・・Add[Floor]to the list
Addltem “ Size line” ・・・Add[Size line]to the list
Addltem “ Window” ・・・Add[Window]to the list
Addltem “Colum” ・・・Add[Colum]to the list
Addltem “Text” ・・・Add[Text]to the list
Addltem “Wall” ・・・Add[Wall]to the list
Private Sub cmd_Ok_Click()
Dim Sname, O_name, N_name As String '
・・・The text column stakes the unstatable nuimber
Sname = "C:\LT2VB\layer\layer.scr"
・・・Create the script file by memo first.
Open Sname For Output As #1
・・・Open the selected file.
O_name = old_Lay.List(old_Lay.ListIndex)
・・・Set the data chosen from[ListBox] in the unstatable text value "O_
name"
N_name = new_Lay.Text
・・・Set the data chosen from[ComboBox] in the unstatable text value "N_
name"
Print #1, "-rename la " & O_name & Chr(13) & N_name & Chr(13) & Chr(13)
・・・The command to replace layer name (Summary No.1)
155154
MainForm.bmp
Volo_00.bmp
AppActivate “ AitoCAD” Activate AutoCAD LT
Activate AutoCAD LT
Sendkey “filedia 0” & Chr(13) & “sprict” & Chr(139 & Sname & Chr(13),Tiue
Send the script file to the AutoCAD LT command line.
End Sub
Chapter 12 Use VoloView Express
AIM Zoom and rotate drawing with the for the thumnail display.
Tip
Summary NO.1 [space between " " functions as Return Key]
“-rename la” & 0_name & Chr(139 & N_name & Chr(13) & Chr(13)
“-rename” AutoCAD LT command [repalce the layer name and the text style.]
Put "_" before the command to undisplay the dialog.
O_name Existing layer
N_name Replacing layer
Chain the code above with "&" to create the script file.
The dialogue to replace the name.
[Step4] Save the program
① Title and save the form of this program.
Choose[File]-[Title and save Form1] ・・・ layer.frm
② Title and save the project of this program.
Choose[File]-[Title and save Project1] ・・・layer.vbp
③ Finaly,create the exe file.
Choose[File]-[Create Project1.exe] ・・・layer.exe
② Choose the file from the list in the left. this graphic appers.
The graphic can be zoomed or rotated with the mouse.
① VB program:Start VoloView(Volo.exe)
157156
Volo_03.bmp
Volo_04.bmp
Volo_04-2.bmp
Volo_01.bmp
Volo_02.bmp
VoloView control
What is VoloView Express?
[VoloView Express]is a dwg/dxf/dwf file displayable free viewer supplied Su-
todesk.
You can download either from the official site of Autodesk.
(http://www.autodesk.co.jp)or from attatched CD-ROM.
(VoloView\VoloEm.exe)
(Before use,read the instructions which are stored in the VoloView1.txt and
VoloView2.txt)
Double click VoloVM.exe to auto-install.
VoloView Express is operatable by it self and also
can be used on VisualBasic as VoloView Express ActiveX control.
We explain how to combine VoloView control with VB this chapter.
Operation ②・・・The commands for
rotating,zooming,orbiting,and so on,
in the window in the right.
O p e r a t i o n ③・・・T o o p e n t h e
file,press[Open the file]
Operation ①・・・Choose the file and press [File display] to display the file.
159158
①
② ③
④
⑤
①
②
③
④
⑤ -1 ⑤ -2 ⑤ -3Volo_05.bmp
Volo_06.bmp
frm_New.bmpf r m _ N e w2.
Procedure on Visual Basic
Create the new form
① Press[OPEN]from the standard exe of [create the new form]tab.
② Replace the caption of Form1 to VoloView.
Create controls
① Apply a <DriveListBox> control from [Standard control]
② Apply a <DirListBox> control from [Standard control]
③ Apply a <FileListBox> control from [Standard control]
④ Apply a <VoloView> control.
⑤ Apply three <CommandButton> controls from [Standard control]
(The object name) for CommandButton1 -> cmd_View
The Caption for CommandButton1 -> Display the file
(The object name) for CommandButton2 -> cmd_Open
The Caption for CommandButton2 -> Open the file
The object name) for CommandButton3 -> cmd_End
The Caption for CommandButton3 -> [End]We use both [VoloView control]and the standard control for this program.
[VoloView control]is not contained in standard tools.
Press [Project]-[component]and choose <Autodesk VoloView Control> from [Con-
trol]tab,then
pick [Apply] to add the control.
Standard-Tab2
161160
Volo_10.bmp Volo_11.bmp
Volo_12.bmp Volo_13.bmp Volo_14.bmp
③ FileListBox(File1) ④ AvViewX(AvViewX1)
⑤ -1(cmd_View) ⑤ -2(cmd_Open) ⑤ -3(cmd_End)
Volo_08.bmp Volo_09.bmp
① DriveListBox(Drive1) ② DirListBox(Dir1)
Volo_07.bmp
163162
Volo_17.bmp
Volo_17-2.bmp
Volo_15.bmp
Volo_16.bmp
① DriveListBox(Drive1)
② DirListBox(Dir1)
② Program the code below in [DirListBox]
Link [File] and [Directory]
Private Sub frm_Open_Click()
Dim openFile As String
・・・The text column states the unstable number.
Receive the file name.
if Right(Dir1.Path,1)= “\” Then
openFile=Dir1.Path & File1.Filename
・・・Receive the selected file name.
Else
openFile=Dir1.Path & File1.Filename
・・・The case "\" in the path.
End if
Read and display the file.
AvViewX1.Src=openFile
・・・Display the file on VoloView window.
End Sub
[Step3] Program
① Program the code below in [Drive List Box]
Link [Drive] and [Directory]
③ Describe the move(the program) when the [Display the file] button is
clicked.
165164
Volo_19.bmp
Volo_18.bmp
Volo_18-2.bmp
④ Describe the move(program) when the [Open the file] button is clicked.
Double click the {Open the file] to program the code below.
⑤ Describe the move(program) when [End] is pressed.
Double click the [End] to program the code below.
Unload Me ・・・ Close this form.
Private Sub cmd_Open_Click()
Dim openFile As String
・・・State the unstable number of the text column.
Dim Sname As String
・・・State the unstable number of the text column.
'Acquire Filename
If Right(Dir1.Path, 1) = "/" Then
openFile = Dir1.Path & File1.FileName
Else
openFile = Dir1.Path & "/" & File1.FileName
End If
Sname = "C:\LT2VB\VoloView\VoloView.scr"
・・・Create the script file by memo first.
Open Sname For Output As #1
・・・Open the file in INPUT/OUTPUT mode.
Print #1, "open " & openFile
・・・Open the file selectec.
Print #1, "filedia 1"
Close #1
AppActivate "AutoCAD"
・・・Activate AutoCAD LT
SendKeys "filedia 0" & Chr(13) & "script" & Chr(13) & Sname & Chr(13),
True
・・・Send the script file to the AutoCAD LT command line.
167166
MainForm.bmp
door_1-01.bmp
door_1-02.bmpdoor_1-03.bmp
door_1-04.bmp
Save the program.
① Title and save the form of this program.
Choose [File]-[Title and save form1]・・・Volo.frm.
② Title and save the form of this program.
Choose [File]-[Title and save project1]・・・Volo.vbp.
③ Create exe file lastly. Choose [File]-[Create Project1.exe]
Chapter13 draw doors(3 kinds)AIM・・・ Draw the parts (the doors) to be inserted into the Auto-
CAD LT drawing.
TIP
① VB program:Start architectual symbol(BlockA.exe)
② Choose one from [Single open door],[Double open door] and [Semi-double open
door] and the dialogue for the selected door is displayed.
Type in the value,then press [Draw].
169168
door_02.bmpdoor_01.bmp
door_03.bmp
③ AutoCAD LT drawing:Open house.dwg first (this file is saved in the folder of
BlockA).
Insert [Semi-double door] in to the drawing below.
Operation ② The window switches to the autoCAD LT.
Pick the conection of the door to the wall to amove any position
in the drawing.
Operation ① Choose [Single open door].
Type <750> in <Door width> and <25> in [Door thickness]
Press [Drow]
171170
door_04.bmp
frm_New.bmpf r m _ N e w2.
① -1
①
②
① -2 ① -3
② -1 ② -2 ② -3
② -4
MainForm ・・・NainBlockA
SubForm ・・・cmd_door1
SubForm ・・・cmd_door2
door_04.bmp
SubForm ・・・cmd_door3
door_1-10.bmp
door_2-01.bmp
door_3-01.bmp
Procedure on VisualBasicAdd three forms to [main BlockA]
(Single open door -> frm_door1,Double open door -> frm_door2,semi double open
door
frm_door3)
[Step1] Create new form
① Choose [Standard exe] from [new file] and press [open],
Then [form1],the new form is made.
② Open the property of Form1 to change the caption to <parametric <architec-
tual use>.
[Step2] Create controls
Standard-Tab2
173172
door_1-05.bmp
door_1-06.bmp
② -1(cmd_Door1)
② -2(cmd_Door2)
② -3(cmd_Door3)
door_08.bmp
door_09.bmp
door_10.bmp
① -1(Label1) ① -2(Label2) ① -3(Label3)
door_05.bmp door_06.bmpdoor_07.bmp
① Apply three <Label> controls from [standard control]
・ The Caption for label1 -> creates the single open door.
・ The Caption for label2 -> creates the double open door.
・ The Caption for label3 -> creates the semi-double open door.
② Apply four <commandbuttomn> controls from [standard control]
・ (The object name) for CommandButton1 -> cmd_door1
・ The picture for CommandButton1 -> (bitmap) ・・・ BlockA
・ The style for CommandButton1 -> 1-graphics
・ (The object name) for CommandButton2 -> Right
・ The picture for CommandButton2 -> (bitmap) ・・・ BlockA
・ The style for CommandButton2 -> 1-graphics
・ (The object name) for CommandButton3 -> Left
・ The picture for CommandButton3 -> (bitmap) ・・・ BlockA
・ The style for CommandButton3 -> 1-graphics
・ (The object name) for CommandButton4 -> End
The caption for CommandButton4 -> [End]
175174
door_1-10.bmp
Standard-Tab2
① -1
①
③① -2
② -1
② -2
③ -1
③ -2
②
③ -3
door_1-07.bmp
[Step3] Program
① Describes the move when [cmd_Door1] is pressed.
① apply two <Label> controls from [standard control]
・ The caption for Label1 -> A-door width.
・ The caption for Label2 -> B-door width.
② apply two <Text Box> controls from [standard control]
・ the text for Text1 -> Blank
・ The object name for Text1 -> length(nagasa)
・ The text for Text2 -> Blank
・ The object name for Text2 -> width(haba)
③ Apply three <CommandButton> from [standard control]
・ (The object name) for CommandButton1 -> cmd_door1
・ The picture for CommandButton1 -> (bitmap) ・・・ BlockA
・ The style for commandButton1 -> 1-graphics
・ (The object name) for CommandButton2 -> cmd_OK1
・ The caption for CommandButton2 -> Draw
・ (The object name) for CommandButton3 ->cmd_End
・ The caption for CommandButton3 -> End frm_door3.Show ・・・ Display (frm_Door3)
MainBlocKA.Hide ・・・ Close (main Form)
② Describes the move when [cmd_Door2] is pressed.
frm_door1.Show ・・・ Display (frm_Door1)
MainBlocKA.Hide ・・・ Close (main Form)
frm_door2.Show ・・・ Display (frm_Door2)
MainBlocKA.Hide ・・・ Close (main Form)
③ Describes the move when [cmd_Door3] is pressed.
Case1 Place controls in [cmd_Door1] and program the code.
[Step4] Create controls
177176
door_1-17.bmp
door_1-15.bmp door_1-16.bmp
③ -2(cmd_Ok1) ③ -3(cmd_End)
door_1-13.bmp
door_1-14.bmp
① -1(Label1) ① -2(Label2)
door_14.bmp door_15.bmp
② -1(TextBox1)
② -2(TextBox2)
door_1-11.bmp
door_1-12.bmp
③ -1(cmd_Door1)
[Step5] Program
① Double click [cmd_Door1] to program the code below.
Copy the same contents to cmd_Ok1.
179178
door_2-01.bmp
① -1
①
③① -2
② -1
② -2
③ -1
③ -2
②
③ -3
① Apply two <label> controls from [standard control]
・ The caption for Label1 -> A-Door width
・ The caption for Label2 -> B-Door width
② Apply two <Text Box> controls from [standard control]
・ The text for Text1 -> Blank
・ (object name) for Text1 -> length(nagasa)
・ The text for Text2 -> Blank
・ (object name) for Text2 -> width(haba)
③ Apply three <CommandButton> controls from [standard control]
・ (object name) for CommandButton1
・ The picture for CommandButton1 -> (bitmap)
・ The style for ComamndButton1 -> graphics.
・ (object name) for CommandButton2
・ The caption for CommandButton2 -> Draw
・ (object name) for CommandButton3
Case2 Place controls in [cmd_door1] to program the code.
[Step6] Create controls
Standard-Tab2
・ The caption for CommandButton3 -> En
Private Sub cmd_Door1_Click()
Dim A, B, X, Sname As String
・・・The text column stakes the unstable number
Dim X1 As Integer
・・・The integral number stakes the unstable number.
Sname = "C:/LT2VB/BlockA/door.scr"
・・・Create the script file by memo first.
A = nagasa
・・・Set the data in [Text Box <length (nagasa)> to A.
B = haba
・・・Set the data in [Text Box <width (haba)> to B
If A = "" Or B = "" Then
MsgBox (“Input the value!”) Exit Sub
End If
Open Sname For Output As #1
・・・Open the file in INPUT/OUTPUT mode.
Print #1, "zoom a"
Print #1, "rectang 0,0 " & A & "," & B
・・・Rectangle Command [left bottom axis <0,0>, right top axis <A,B>]
Print #1, "select l "
Print #1, "arc c 0,0 " & A & ",0 a 90"
・・・Circular line command [the center point axis <0,0>,the starting point
axis <A,0>,Angle <90° >]
Print #1, "select l p "
Print #1, "line 0,0 0," & A & Chr(13)
・・・Line command [the starting point axis <0,0>,the end point axis <0,A>]
Print #1, "select l p "
Print #1, "filedia 1"
Print #1, "move p 0,0"
・・・Move command [the initial point axis <0,0>,the destination can be
picked.]
Close #1
AppActivate "AutoCAD"
・・・Activate AutoCAD LT
SendKeys "filedia 0" & Chr(13) & "script" & Chr(13) & Sname & Chr(13) , True
・・・Send the script file to AutoCAD LT
End Sub
181180
door_2-08.bmp
door_2-06.bmpdoor_2-07.bmp
③ -2(cmd_Ok2)③ -3(cmd_End)
③ -4(cmd_End)
door_2-07-2.bmp
door_2-02.bmp door_2-03.bmp
door_2-04.bmp
① -1(Label1) ① -2(Label2)
② -2(TextBox2)
③ -1(CommandButton-cmd_Door2)
door_14.bmp door_15.bmp
door_1-13.bmp
② -1(TextBox1)
[Step7] Program
1.Double click [cmd_Door2] to program the code below.
(Copy same contents to cmd_Ok2)
183182
door_2-09.bmp
② Double click [end] to program the code below.
MainBlockA.show ・・・ Display main Form
Unload Me ・・・ Close this Form
Private Sub cmd_Door2_Click()
Dim A, B, X, Sname As String
・・・The text column stakes the unstable number.
Dim X1 As Integer
・・・The integral number stakes the unstable number.
Sname = "C:\LT2VB\BlockA\door.scr"
・・・Create the script file by memo first.
A = nagasa
・・・Set the data in [Text Box <length(nagasa)> to A.
B = haba
・・・Set the data in [Text Box <width(haba)> to B
If A = "" Or B = "" Then
MsgBox (“Input the value!”) Exit Sub
End If
Open Sname For Output As #1
・・・Open the file in INPUT/OUTPUT mode.
X1 = CInt(A) + CInt(A)
・・・A is half the length of the door board,so calculate by 2
To get whole length of the board.
X = Str(X1)
・・・Convert the value in to Text column.
Print #1, "rectang "; "0,0" & X & "," & B
・・・Rectangle command [Bottom left axis <0,0>,Uper rightAxis <X,B>]
Print #1, "select l "
Print #1, "arc c 0,0 " & A & ",0 a 90"
・・・Circular line command [center point axis <0,0>,starting point axis<A,0>,
angle <90° >]
Print #1, "select l p "
Print #1, "arc c" & X & ",0 " & A & ",0 a -90"
・・・Circular line command [center point axis <X,0>,starting point axis <A,0>,
angle <-90° >]
Print #1, "select l p "
Print #1, "line @" & X & "," & A & Chr(13)
・・・Line command [starting point axis <last point>,end point axis <X,A>]
Print #1, "select l p "
Print #1, "line 0,0 0," & A & Chr(13)
・・・Line command [starting point axis <0,0>,end point axis <0,A>]
Print #1, "select l p "
Print #1, “filedia 1”
Print #1, “move p 0,0”
・・・Move Command [initial point axis <0,0>, the destination can be picked.]
Close #1
AppActivate “AoutCAD”
・・・Activate AutoCAD LT
Sendkeys “filedia 0” & Chr(13) & “script” & Chr(13) & Sname & Chr(13),True
・・・Send the script file to autoCAD LT command line.
185184
door_3-02.bmp
door_3-03.bmp
door_3-04.bmp door_3-05.bmp door_3-06.bmp
① -1(Label1) ① -2(Label2)
door_16.bmp door_15.bmp
① -③ (Label3)
door_17.bmp
② -1(TextBox1) ② -2(TextBox2) ② -3(TextBox3)
③ -1(cmd_Door3)
① -1
①
③ ① -2
② -1
② -2
③ -1
③ -2
②
③ -3
door_3-01.bmp
① -3
② -3
① Apply three <label> controls from [standard control]
・ The caption for Label1 -> A-width of bigger door
・ The caption for Label2 -> B-thickness of doors
・ The caption for Label3 -> C-length of smaller door
② Apply three <TextBox> controls from [standard control]
・ The text for Text1 -> Blank
・ (object name) for Text1 -> length(nagasa)
・ The text for Text2 -> Blank
・ (object name) for Text2 -> width(haba)
・ The text for Text3 -> Blank
・ (object name) for Text3 -> length(nagasa2)
③ Apply three <CommandVutton> controls from [standard control]
・ (object name) for CommandButton1
・ The picture for CommandButton1 -> (bitmap) BlockA
・ The style for CommandButton1 -> 1-graphics
・ (object name) for CommandButton2
・ The caption for CommandButton2 -> Draw
・ (object name) for CommandButton3
・ The caption for CommandButton3 -> End
Case3 Place controls in [cmd_Door3] to program the code
[Step8] Create controls
Standard-Tab2
187186
door_3-07.bmp door_3-08.bmp
③ -2(cmd_Ok3) ③ -3(cmd_End)
door_3-09.bmp
[Step9] Program
① Double click [cmd_Door3] to program the code below.
(Copy same contents to cmd_Ok2)
Private Sub cmd_Door3_Click()
Dim A, B, C, X, Sname As String
・・・The text column stakes the unstable number.
Dim X1 As Integer
・・・The integral number stakes the unstable number.
Sname = "C:\LT2VB\BlockA\door.scr"
・・・Create the script file by memo first.
A = nagasa1
・・・Set the data for [Text box <length(nagasa)>] to A.
B = haba
・・・Set the data for [Text box <width(haba)>] to A
C = nagasa2
・・・Set the data for [Text box <length(nagasa2)>] to A
If A = "" Or B = "" Then
MsgBox (“Input the value!”) Exit Sub
End If
Open Sname For Output As #1
・・・Open the file in INPUT/OUTPUT mode.
X1 = CInt(A) + CInt(C)
・・・Calculate the width of doors of semi-double door.
X = Str(X1)
・・・Convert into the text column.
Print #1, "rectang "; "0,0" & X & "," & B
・・・Rectangle Command [Bottom left axis <0,0>,Upper right axis <X,B>]
Print #1, "select l "
Print #1, "arc c 0,0 " & A & ",0 a 90"
・・・Circular line command [center point axis <0,0>,starting point axis
<A ,0>,Angle<90° >]
Print #1, "select l p "
Print #1, "line 0,0 0," & A & Chr(13)
・・・Line command [Starting point axis <0,0>,end point axis <0,A>,Angle
<-90° >]
Print #1, "select l p "
Print #1, "arc c" & X & ",0 " & A & ",0 a -90"
・・・Circular line command [center point axis <X,0>,starting point axis
<A,0>,
Angle <-90° >]
189188
mach_1-01.bmp
mach_1-02.bmpmach_1-03.bmp
mach_1-04.bmp
MainForm.bmp
door_3-10.bmp
Chapter 14・・・Create screws (3 kinds)
Aim・・・Create screws to insert into AutoCAD LT drawing
Tip
① VB program : Start [symbol (mechanical use) <Block. exe>]
[Step10] Save the program
① Title and save the form of this program.
Choose [file]-[title and save form1]・・・MainBlockA.frm
② Title and save the project of this program.
Choose [file]-[title and save project1]・・・BlockA.vbp
③ Finally,create exe file
Choose [file]-[create project1.exe]・・・BlockA.exe
MainBlockA.Show ・・・ Display main form
Unload Me ・・・ Close this form
② Choose one from [plain head], [round dish head] and [flat dish head]to dis-
play its dialogue.
Type in the value and press [Draw]
Print #1, "line @" & X & "," & C & Chr(13)
・・・Line command [Starting point axis <last axis>,end point axis <X,G>]
Print #1, "select l p "
Print #1, "filedia 1"
Print #1, "move p 0,0"
・・・Move command [initial point axis <0,0>,destination can be picked]
Close #1
AppActivate "AutoCAD"
・・・Activate AutoCAD LT
SendKeys "filedia 0" & Chr(13) & "script" & Chr(13) & Sname & Chr(13), True
・・・Send the script file to AutoCAD LT command line.
Double click [End] to program the code below.
191190
mach_03.bmp
mach_01.bmp
mach_02.bmp
Operation ①・・・Choose [Plain head]
Type <15> in [A], <40> in [C],<10> in [D]
Press [draw]
Operation ②・・・The window switches to the AutoCAD LT.
Pick the point on the picture to locate the
screw.
③ AutoCAD LT drawing :Open machin. dwg first.
(This file is stored in the folder of Block B)
193192
mach_1-05.bmp
①
②
③
④
①
② -1
② -2
② -3
③
④ -1 ④ -2
MainForm ・・・NainBlockB
SubForm ・・・machin1
SubForm ・・・machin2
SubForm ・・・machin3
mach_1-05.bmp
mach_04.bmp
mach_05.bmp
mach_06.bmp
Procedure on visual Basic Add thee forms into [Main Block B]
Plain head → machin1, round head → machin2, flat head → machin3
Create new form
①Choose [Standard ExE] from [NEW FILE] and press [OPEN], then [Form1], the
new form is opened.
②Open the property of Form 1 to change the caption to <parametric <mechani-
cal use>
Create Controls.
Standard- Tab2.
195194
mach_1-13.bmp
mach_1-11.bmp mach_1-12.bmpmach_1-10.bmp
③ (Image1) ④ -1(cmd_End) ④ -2(cmd_Next)
mach_1-06.bmp mach_1-07.bmp mach_1-08.bmp
① (Frame1)
mach_1-09.bmp
② -1(Option(0)) ② -2(Option(1)) ② -3(Option(2))
②Apply three <Option Button> controls from [Standard control]
The caption for Option 1(0) → Plain head
The Value for Option 1(0) → True.
The caption for Option 1 (1) → round head
The Value for Option 1(1) → False
The caption for Option 1 (2) → flat head
The Value for Option 1(2) → False
③Apply <Image> control from [Standard control ]
The picture for Image 1 → NONE
④Apply two <command Button> controls from [Standard control]
(object name ) for command button 1. → com_End
Caption for command button 1 → [End]
(object name ) for command button 2. → com_Next
Caption for command button 2 → [details]
[Step3] Program
① Choose the bitmap to display on [Image1] when [Option] is clicked.
① Apply a <Frame> control from [Standard control]
The caption for Frame → cross hole screw
Private Sub Option1_Click(Index As Integer)
If Option1(0).Value = True Then
Image1.Picture = LoadPicture("C:/LT2VB/BlockB/machin1.bmp")
End If ・・・Display <machin 1. bmp> in [Image1] when.
Option 1 (0) is pressed.
If Option1(1).Value = True Then
Image1.Picture = LoadPicture("C:/LT2VB/BlockB/machin2.bmp")
End If ・・・Display <machin 2. bmp> in [Image1] when.
Option 1 (1) is pressed.
If Option1(2).Value = True Then
Image1.Picture = LoadPicture("C:/LT2VB/BlockB/machin3.bmp")
End If ・・・Display <machin 3. bmp> in [Image1] when.
Option1(2) is pressed.
197196
mach_04.bmp
①
①
③
④ -2
② -1 ② -2
③ -1 ③ -2
④
③ -3
② -3 ② -4
③ -4
④ -1
②
mach_1-14.bmp
①Apply <Image> control from [Standard control ]
②Apply four <Label> controls from [Standard control]
The caption for Label 1 -> A
The caption for Label 2 -> B
The caption for Label 3 ->C
The caption for Label 4 -> D
③Apply four <Text Box> controls from [Standard control]
The text for Text 1 -> Blank
(object name ) for Text 1 ->txtA
The text for Text 2 -> Blank
(object name ) for Text 2 ->txtB
The text for Text 3 -> Blank
(object name ) for Text 3 ->txtC
The text for Text 4 -> Blank
(object name )for Text 4 ->txtD
Apply four <Text Box> controls from [Standard control]
② Choose the sub form to display when [cmd _ Next] is clicked Case1 Place controls in [machin 1] and program the code
[Step4] Create controls
Standard-Tab2
Private Sub cmd_Next_Click()
If Option1(0).Value = True Then
machin1.Show ・・・Display [machin 1] when Option1 (0)
is pressed.
End If
If Option1(1).Value = True Then
machin2.Show ・・・Display [machin 2] when Option1 (1)
is pressed.
End If
If Option1(2).Value = True Then
machin3.Show ・・・Display [machin 3] when Option1 (2)
is pressed.
199198
mach_1-23.bmp mach_1-24.bmp
④ -1(cmd_Ok) ④ -2(End)
mach_1-25.bmp
mach_1-17.bmp
mach_1-18.bmp
① (Image1)
mach_1-19.bmp mach_1-20.bmp mach_1-21.bmp mach_1-22.bmp
③ -1(txtA) ③ -2(txtB) ③ -3(txtC) ③ -4(txtD)
④Apply two < command Button > controls from [Standard control]
(object name ) for command Button 1 -> cmd_OK
Caption for command button 1 -> [Draw]
(object name ) for command Button 2 -> End
Caption for command button 2 -> [End]
Program
① Double click [cmd _OK] to program the code below
201200
Private Sub cmd_Ok_Click()
Dim A, B, C, D, X, Sname As String
・・・The text column states the unstable number.
Dim X1 As Integer
・・・The integral number states the unstable number.
Sname = "C:\LT2VB\BlockB\neji.scr"
・・・Create the script file by MEMO first
A = txtA(0)
・・・Set the data of [Text Box <txtA> to A
B = txtB(1)
・・・Set the data of [Text Box <txtB> to A
C = txtC(2)
・・・Set the data of [Text Box <txtC> to A
D = txtD(3)
・・・Set the data of [Text Box <txtD> to A
If A = "" Or B = "" Then
MsgBox (In put the value!)
Exit Sub
End If
X1 = CInt(A) - CInt(D)
X1 = 0.5 * X1
Open Sname For Output As #1
・・・Open the file in input /output mode.
Print #1, "-osnap non"
・・・Unlock the [normal O snap] mode.
Print #1, "rectang "; "0,0 " & B & "," & A
・・・Rectangle command [Bottom left axis <0,0>,Upper right axis <X,B>]
Print #1, "select l "
Print #1, "line " & B & "," & X1 & Chr(13) & "@" & C & "," & "0" &
Chr(13)
・・・Line Command (Summary NO.1)
Print #1, "select l p "
Print #1, "select l p "
Print #1, "line @ " & "@0" & "," & D & Chr(13)
・・・Line Command (Summary NO.2)
Print #1, "select l p "
Print #1, "line @ " & "@-" & C & "," & "0" & Chr(13)
・・・Line Command (Draw from last point to the point X=- C,Y=0)
Print #1, "select l p "
Print #1, "filedia 1"
Print #1, "move p 0,0"
Close #1
AppActivate "AutoCAD"
・・・Activate AutoCAD LT
SendKeys "filedia 0" & Chr(13) & "script" & Chr(13) & Sname & Chr(13), True
・・・Send the script file to AutoCAD LT command line.
End Sub
Summary NO.1 [Space between ・・functions as Return key]
"line " & B & "," & X1 & Chr(13) & "@" & C & "," & "0" & Chr(13)
“line ”・・・AutoCAD LT Command [Draw lines]
B,X1・・・starting point axis
@C,0・・・end point axis
Chain the code above with ・・to create the script file
Summary No.1 1 [Space between ・・functions as Return key]
"line @ " & "@0" & "," & D & Chr(13)
“line ”・・・AutoCAD LT Command [Draw lines]
@ ・・・starting point axis (Same as 0,0)
@0,D ・・・end point axis
Chain the code above with ・・to create the script file
203202
MainForm.bmp
civil-01.bmp
civil03.bmp
Save the program
①Title and save the form of this program
Choose [File] - [Title and save Form1] ・・・MainBlockB.frm
②Title and save the project of this program
Choose [File] - [Title and save project 1] ・・・BlockB,vbp
Finally, create exe file.
Choose [File] - [Create project, exe] ・・・Block.exe
Chapter 15・・・Parametric drawings (Constructional
use)
Aim
Import Excel data to VB to draw a ditch on AutoCAD LT
TIP
②Auto CAD LT drawing : Open [side picture. dwg]
(the drawing is blank)
[Side picture, dwg] is stored in the folder of Block C
①VB program : Start symbol (constructional use) <txt4,exe>
205204
C:/LT2VB/BlockC/CivilData.xls
civil-03.bmp
civil04.bmp
civil05.bmp
frm_New.bmpf r m _ N e w2.
t x t _ N o5-05.
② Link [data control] with the Excel text spreadsheet.
(The Excel sheet name has to be specified)
③Change [Property] of [data control][object name <Data1>]
・Caption -> PI Pre cast L shaped ditch.
・Connect -> Excel8.0
・DatabaseName -> CivilData.xls
・Recordsource -> L shaped ditch
[Step2] Paste data controls
① Press [data control] to create controls in form1
(the Object name <Data1>)
*By switching the record source, it can be linked with other data
bases.
Standard Tool
[Step1]・・・Create a new form
① Chose[StandardEXE] form [NEW FILE] and press [OPEN],then [Forml],
the new form is opened
② Open the property of form 1 to change the caption to
<Parametric (constructional use)>
207206
civil-07.bmp
civil-08.bmp
① (Image1)
civil06.bmp
③ -1(txt_A)
civil-03.bmp
Standard_Tab2
①
② ③
④
civil-02.bmp
①
② -1
③ -1
④ -1
civil-02.bmp
④ -2
[Step3]・・・Create controls
① Apply <Image> control from [Standard control ]
・Image1 Picture -> Civil.bmp ・・・In the folder of Block C
② Apply10 <Label> controls from [Standard control ]
・The caption for Label 1 -> A
Locate Same thing for Label 2 to Label 10
③ Apply10 <Text Box> controls from [Standard control ]
・(object) for Text 1 → txtA
・Text for Text 1 → Blank
・Data field for text 1 -> A
・Data source for text 1e -> Data1
Repeat same steps for Text 2 to Text 10
④ Apply2 < command button > controls from [Standard control ]
・Cobject name for Command1 -> cmd_Ok
・Caption for Command1 -> [Draw]
・(Object name)for Command2 -> End
・Caption for Command2 -> [End] DataSource -> Data1 ・・・Link with [data control]
(CivilData.xls)
DataField -> Link with Acolumm(2nd) of
CivilData.xls
209208
civil-09.bmp
civil07.bmp civil08.bmp
④ -1(cmd_Ok) ④ -2(End)
Program
② Double click [cmd _OK] to program the code below.
Private Sub cmd_Ok_Click()
Dim A, B, C, D, E, F, G, H, I, X, Sname As String
・・・The text column stares the unstable number
Dim X1, X2, X3, X4, X5, X6 As Integer
・・・The integral number states the unstable number
Sname = "C:/LT2VB/BlockC/civil.scr"
・・・Create the script file by MEMO first
A = txt_A
・・・Set the data in [Text Box <txt _ A>] to A
(Repeat same steps for the rest)
B = txt_B
C = txt_C
D = txt_D
E = txt_E
F = txt_F
G = txt_G
H = txt_H
I = txt_I
J = txt_J
If A = "" Or B = "" Then
MsgBox (“input the value!”)
Exit Sub
End If
X1 = CInt(A) + CInt(B) + CInt(C)
・・・Add A, B and set to x1 (x2 to x6 in summary NO.1)
X2 = CInt(D) + CInt(E) + CInt(F)
X3 = CInt(E) + CInt(F)
X4 = CInt(F) - CInt(I) + J / H * 100
X5 = J / H * 100
X6 = CInt(I) + CInt(E)
211210
Summary No.1
X1・・・CInt(A) + CInt(B) + CInt(C)
X2・・・CInt(D) + CInt(E) + CInt(F)
X3・・・Cint(E) + Cint(F)
X4・・・CInt(F) - CInt(I) + J/H * 100
X5・・・J/H * 100
X6・・・Cint(I) + Cint(E)
Save the program.
① Title and save the form of this program.
Choose [File]- [Title and save Form 1]・・・MainBlockC.frm
② Title and save the project of this program.
Choose [File]- [Title and save project 1]・・・BlockC.vbp
③ Finally, create exe file
Choose [File]- [Create project 1.exe]・・・BlockC.exe
Convert the unstable text value A to numerical value
Open Sname For Output As #1
Print #1, "-osnap non"
Print #1, "rectang " & "0,0 " & X1 & "," & D
・・Rectangle command [bottom left axis<0,0>,Upper right axis <X1,0>]
Print #1, "select l "
Print #1, "line " & A & "," & D & Chr(13) & "@" & "0" & "," & X3 &
Chr(13)
・・Line command [the starting point axis <A,D>, the end point axis <@0,X3>]
Print #1, "select l p "
Print #1, "line @ " & "@" & G & "," & "0" & Chr(13)
・・Line command [the starting point axis <last point>, the end point
axis <@G,0>]
Print #1, "select l p "
Print #1, "line @ " & "@" & "0" & ",-" & X4 & Chr(13)
・・Line command [the starting point axis <last point>, the end point
axis <@G,0>]
Print #1, "select l p "
Print #1, "line @ " & "@" & H & "," & X5 & Chr(13)
・・Line command [the starting point axis <last point>, the end point
axis <@H,5>]
Print #1, "select l p "
Print #1, "line @ " & "@" & "0" & ",-" & X6 & Chr(13)
・・Line command [the starting point axis <last point>, the end point
axis <@0,- X6>]
Print #1, "select l p "
Print #1, "line " & "@" & "0" & "," & E & Chr(13) & "@-" & B & "," &
"0" & Chr(13)
・・Line command [the starting point axis <@0,E>, the end point axis <@- B,0>]
Print #1, "select l p "
Print #1, "filedia 1"
Print #1, "move p 0,0"
・・Move command [the initial point <0,0>,the destination can be picked]
Close #1
213212
Private Sub Form_layer_Click(Index As Integer)
Shell "C:/LT2VB/layer/layer.exe", vbNormalFocus
End Sub
Private Sub frm_VoloView_Click()
Shell "C:/LT2VB/VoloView/Volo.exe", vbNormalFocus
End Sub
Private Sub Form_BlockA_Click(Index As Integer)
Shell "C:/LT2VB/BlockA/BlockA.exe", vbNormalFocus
End Sub
Private Sub Form_BlockN_Click()
Shell "C:/LT2VB/BlockB/BlockB.exe", vbNormalFocus
End Sub
Private Sub Form_BlockC_Click(Index As Integer)
Shell "C:/LT2VB/BlockC/BlockC.exe", vbNormalFocus
End Sub
Private Sub End_Click()
End
End Sub
Private Sub txt1_Click(Index As Integer)
Shell "C:/LT2VB/text/txt1.exe", vbNormalFocus
End Sub
Private Sub Txt4_Click()
Shell "C:/LT2VB/text/txt4.exe", vbNormalFocus
End Sub
Private Sub frm_Balloon_Click()
Shell "C:/LT2VB/balloon/balloon.exe", vbNormalFocus
End Sub
Private Sub Form_zumen_Click(Index As Integer)
Shell "C:/LT2VB/zumen/zumen.exe", vbNormalFocus
End Sub
①
②
③
④
⑤
⑥
⑦
⑧
⑨
①
②
③
④
⑤
⑥
⑦
⑧
⑨
Last Chapter Combine and store all the programs
into one form