急急急~~!怎么样点击图形,弹出对话框窗体来输入参数!~~~
<P>我通过输入参数的窗体输入参数,然后画了一个图形,画完图,我怎么在次点击图的时候在次让它弹出参数窗体,然后我可以从新输入参数,来从新画图,或者改变图的大小??</P>
<P><BR> </P> <P>Option Explicit</P>
<P> </P>
<P>'定义图形的12条边界线<BR>Global lineobject(0 To 11) As AcadLine<BR>'定义图形面域<BR>Global regionobject As Variant<BR> '定义图形拉伸后的实体<BR>Global solidobject As Acad3DSolid</P>
<P><BR>'定义图形的宽度、高度和厚度等参数<BR>Global beamwidth As Double<BR>Global beamheight As Double<BR>Global beamwebthickness As Double<BR>Global solidlength As Double<BR>Global beammi As Double<BR>Global beamsectmod As Double<BR>Global beamexists As Boolean<BR>Global buffblock As AcadBlock</P>
<P><BR>Public Sub createibeam(width As Double, height As Double, webthickness As Double, solcdlength As Double)</P>
<P> definebeam width, height, webthickness<BR> <BR> regionobject = buffblock.AddRegion(lineobject)<BR> Set solidobject = ThisDrawing.ModelSpace.AddExtrudedSolid(regionobject(0), solidlength, 0)<BR> beamexists = True<BR> Dim vportobj As Object<BR> Set vportobj = ThisDrawing.Viewports.Add("IBEAMVIEWPORT")<BR> ThisDrawing.ActiveViewport = vportobj<BR> <BR> <BR> Dim newdirection(0 To 2) As Double<BR> newdirection(0) = 1#<BR> newdirection(1) = -1#<BR> newdirection(2) = 1#<BR> vportobj.Direction = newdirection<BR> ThisDrawing.ActiveViewport = vportobj<BR> <BR> <BR>End Sub</P>
<P><BR>Public Function checkrules(width As Double, height As Double, webthickness As Double) As Boolean<BR> Dim webheight As Double<BR> <BR> If (width > 0) And (height > 0) And (webthickness > 0) Then<BR> webheight = height - 2 * webthickness<BR> If webheight <= 0 Then<BR> Exit Function<BR> End If<BR> If (width > webthickness) And (height > webheight) And (webthickness >= width / 6) And (webheight >= width / 4) Then<BR> checkrules = True<BR> End If<BR> End If<BR>End Function</P>
<P>Sub IBEAMVBA()<BR> UserForm1.Show<BR>End Sub<BR>Private Sub definebeam(width As Double, height As Double, webthickness As Double)<BR> Dim x(0 To 11) As Double<BR> Dim y(0 To 11) As Double<BR> Dim z As Double<BR> z = 0<BR> <BR> Dim halfflange As Double<BR> halfflange = (width - webthickness) / 2<BR> Dim halfht As Double<BR> halfht = height - 2 * webthickness<BR> <BR> <BR> x(0) = 0<BR> y(0) = 0<BR> x(1) = x(0) + width<BR> y(1) = y(0)<BR> x(2) = x(1)<BR> y(2) = y(1) + webthickness<BR> x(3) = x(2) - halfflange<BR> y(3) = y(2)<BR> x(4) = x(3)<BR> y(4) = y(3) + halfht<BR> x(5) = x(2)<BR> y(5) = y(4)<BR> x(6) = x(5)<BR> y(6) = y(5) + webthickness<BR> x(7) = x(0)<BR> y(7) = y(6)<BR> x(8) = x(0)<BR> y(8) = y(5)<BR> x(9) = x(8) + halfflange<BR> y(9) = y(4)<BR> x(10) = x(9)<BR> y(10) = y(2)<BR> x(11) = x(0)<BR> y(11) = y(2)<BR> <BR> Dim inspt(0 To 2) As Double<BR> inspt(0) = 0<BR> inspt(1) = 0<BR> inspt(2) = 0<BR> <BR> Set buffblock = ThisDrawing.Blocks.Add(inspt, "buffblock")<BR> <BR> Dim startpoint(0 To 2) As Double<BR> Dim endpoint(0 To 2) As Double<BR> Dim i As Integer<BR> Dim j As Integer<BR> For i = 0 To 11<BR> startpoint(0) = x(i)<BR> startpoint(1) = y(i)<BR> startpoint(2) = 0<BR> j = i + 1<BR> If i = 11 Then<BR> j = 0<BR> End If<BR> endpoint(0) = x(j)<BR> endpoint(1) = y(j)<BR> endpoint(2) = 0<BR> If beamexists Then<BR> lineobject(i).startpoint = startpoint<BR> lineobject(i).endpoint = endpoint<BR> Else<BR> Set lineobject(i) = buffblock.AddLine(startpoint, endpoint)<BR> End If<BR> Next<BR>End Sub</P>
<P><BR>Public Sub updatabeam(width As Double, height As Double, webthickness As Double, solidlength As Double)<BR> definebeam width, height, webthickness<BR> <BR> regionobject(0).Erase<BR> regionobject = buffblock.AddRegion(lineobject)<BR> <BR> solidobject.Erase<BR> Set solidobject = ThisDrawing.ModelSpace.AddExtrudedSolid(regionobject(0), solidlenght, 0)<BR> <BR> ThisDrawing.ActiveViewport.ZoomExtents<BR> beamexists = True<BR> <BR> <BR>End Sub</P>
<P><BR>Public Function momentofinteria(width As Double, height As Double, webthickness As Double) As Double<BR> <BR> Dim webht As Double<BR> webht = height - 2 * webthickness<BR> <BR> momentofinteria = (width * height * height - webthickness * webht * webht * webht) / 12<BR>End Function</P>
<P>Public Function sectionmodulus(width As Double, height As Double, webthickness As Double) As Double<BR> Dim mi As Double<BR> <BR> mi = momentofinteria(width, height, webthickness)<BR> sectionmodulus = (mi * 12) / (6 * height)</P>
<P>End Function </P>
<P>这是模块里的程序</P> <P>'<BR>'Sub rotate_3Dbox()<BR>' Dim boxobj As Acad3DSolid<BR>' Dim length As Double<BR>' Dim width As Double<BR>' Dim height As Double<BR>' Dim center(0 To 2) As Double<BR>'<BR>' center(0) = 5<BR>' center(1) = 5<BR>' center(2) = 0<BR>' length = 5<BR>' width = 7<BR>' height = 9<BR>'<BR>'<BR>' Set boxobj = ThisDrawing.ModelSpace.AddBox(center, length, width, height)<BR>'End Sub</P>
<P><BR>Option Explicit</P>
<P><BR>Private Sub cmdcreatebeam_Click()</P>
<P> beamwidth = Scrlwidth.Value<BR> beamheight = Scrlheight.Value<BR> beamwebthickness = Scrlthickness.Value<BR> solidlength = scrllength.Value<BR> <BR> If checkrules(beamwidth, beamheight, beamwebthickness) Then<BR> createibeam beamwidth, beamheight, beamwebthickness, solidlength<BR> updatamomentandsection beamwidth, beamheight, beamwebthickness<BR> Else<BR> MsgBox "sorry,the beam cannot be created with your settings.", vbExclamation<BR> <BR> <BR> If Not (beamexists) Then<BR> MsgBox "defult setting restored.", vbInformation<BR> <BR> <BR> Scrlwidth.Value = 650<BR> Scrlheight.Value = 650<BR> Scrlthickness.Value = 125<BR> scrllength.Value = 200<BR> End If<BR>End If<BR> <BR>End Sub</P>
<P>Private Sub cmdquit_Click()<BR> Unload Me<BR>End Sub</P>
<P>Private Sub Label8_Click()</P>
<P>End Sub</P>
<P>Private Sub Scrlheight_Change()<BR> If beamexists = True Then<BR> If checkrules(beamwidth, Scrlheight.Value, beamwebthickness) Then<BR> beamheight = Scrlheight.Value<BR> <BR> updatabeam beamwidth, beamheight, beamwebthickness, solidlength<BR> updatamomentandsection beamwidth, beamheight, beamwebthickness<BR> Else<BR> Scrlheight.Value = beamheight<BR> End If<BR> End If<BR>End Sub</P>
<P>Private Sub scrllength_Change()<BR> If beamexists Then<BR> solidlength = scrllength.Value<BR> <BR> updatabeam beamwidth, beamheight, beamwebthickness, solidlength<BR> updatamomentandsection beamwidth, beamheight, beamwebthickness<BR> End If<BR>End Sub</P>
<P>Private Sub Scrlthickness_Change()<BR> If beamexists Then<BR> If checkrules(beamwidth, beamheight, Scrlthickness.Value) Then<BR> beamwebthickness = Scrlthickness.Value<BR> <BR> updatabeam beamwidth, beamheight, beamwebthickness, solidlength<BR> updatamomentandsection beamwidth, beamheight, beamwebthickness<BR> Else<BR> Scrlthickness.Value = beamwebthickness<BR> End If<BR> End If<BR>End Sub</P>
<P>Private Sub Scrlwidth_Change()<BR> If beamexists Then<BR> <BR> If checkrules(Scrlwidth.Value, beamheight, beamwebthickness) Then<BR> beamwidth = Scrlwidth.Value<BR> <BR> <BR> updatabeam beamwidth, beamheight, beamwebthickness, solidlength<BR> updatamomentandsection beamwidth, beamheight, beamwebthickness<BR> Else<BR> <BR> Scrlwidth.Value = beamwidth<BR> End If<BR> End If<BR> <BR> <BR> <BR>End Sub</P>
<P>Private Sub UserForm_Click()</P>
<P>End Sub</P>
<P>Private Sub UserForm_Initialize()<BR> Scrlwidth.Value = 650<BR> Scrlheight.Value = 650<BR> Scrlthickness.Value = 125<BR> scrllength.Value = 200<BR> <BR>End Sub</P>
<P> </P>
<P>Private Sub updatamomentandsection(beamwidth#, beamheight#, beamwebthickness#)<BR> beammi = momentofinteria(beamwidth, beamheight, beamwebthickness)<BR> beamsectmod = sectionmodulus(beamwidth, beamheight, beamwebthickness)<BR> <BR> Label8.Caption = Format(beammi, "0.0000E+00")<BR> Label7.Caption = Format(beamsectmod, "0.0000E+00")<BR>End Sub</P>
<P>Private Sub UserForm_Terminate()<BR> Set solidobject = Nothing<BR> Dim entry As Object<BR> <BR> For Each entry In ThisDrawing.Blocks<BR> If entry.Name = "BUFFBLOCK" Then<BR> buffblock.Delete<BR> End If<BR> Next<BR> <BR> beamexists = False<BR>End Sub<BR></P>
<P>这是窗体程序,现在的问题就是想点击画的图就弹出窗体</P> 通过窗体的ObjectModified事件来做。。。 ObjectModified事件?????你能说的详细点么??我以前没有没有接触过这个时间~~~我上面发的有代码,ObjectModified事件加在哪呢?怎么加,先谢谢了~~~
页:
[1]