有关曾经发布螺栓源码中的一点问题?
Public Sub m(d1, h, c, d, r, k, s, c2, dw As Double)'设置环境参数,不设置任何捕捉<BR>Dim sysOSMODE As Integer<BR>sysOSMODE = ThisDrawing.GetVariable("osmode")<BR>ThisDrawing.SetVariable "osmode", 0
'设置初始化用户输入状态<BR>ThisDrawing.Utility.InitializeUserInput 32
On Error Resume Next '错误状态处理<BR>Dim fp, sp As Variant
'捕捉用户输入点<BR>fp = ThisDrawing.Utility.GetPoint(, "请输入螺栓前视图的中心点:")<BR>sp = ThisDrawing.Utility.GetPoint(fp, "请输入螺栓侧视图的基准点:")<BR>l = ThisDrawing.Utility.GetDistance(, "请输入螺栓长度 L:")<BR>rotsita = ThisDrawing.Utility.GetAngle(, "请输入螺栓的旋转角度<0>:")
'错误状态处理<BR>If Err Then<BR> rotsita = 0#<BR> Err.Clear<BR>End If
'设SP点为侧图绘图基准点,xzom为X方向坐标,yzom为Y方向坐标<BR>xzom = sp(0) + 0<BR>yzom = sp(1) + 0
'定义AP为系列定义参数,<BR>Dim ap As Variant<BR>Dim utilObj As Object<BR>Set utilObj = ThisDrawing.Utility
utilObj.CreateTypedArray ap, vbDouble, xzom, yzom, 0<BR>If s >= l Then<BR> s = l - 2# * k<BR>End If
hrad = d / 2#
Dim mx As String<BR> mx = "M" & CStr(Fix(d1)) & CStr(Fix(h)) & CStr(Fix(l))<BR> mmx = mx
'绘制螺栓前视图的圆<BR> Dim circ As AcadCircle<BR> Set circ = ThisDrawing.ModelSpace.AddCircle(fp, hrad)
'绘制螺栓前视图的六边形<BR> Dim fpstr As String<BR> fpstr = fp(0) & "," & fp(1) & "," & fp(2)<BR> ThisDrawing.SendCommand ("_polygon" & vbCr & "6" & _<BR> vbCr & fpstr & vbCr & "c" & vbCr & hrad & vbCr)
'****************************************************<BR>'定义当前图层设置。<BR>Dim flagno As Integer<BR>flagno = 0
Dim iblock As Integer<BR>iblock = ThisDrawing.Blocks.Count<BR>While (iblock > 0)<BR> If ThisDrawing.Blocks.Item(iblock - 1).Name = mx Then<BR> flagno = 1<BR> End If<BR> iblock = iblock - 1<BR>Wend
<BR>If flagno = 0 Then<BR> Dim layerold As Integer<BR> layerold = ThisDrawing.GetVariable("clayer")<BR>'设置各点参数值<BR> rr = r<BR> c40 = c / 4#<BR> ax0 = ap(0)<BR> ax1 = ax0 - h<BR> ax2 = ((c / 2# - d / 2#) / 1.732 + ax0) - h<BR> ax3 = (1.5 - 1.414) * d1 + ax0 - h<BR> ax5 = ax0 + rr + c2<BR> ax6 = ax0 - s + l - d1 / 5# + c2<BR> ax7 = ax0 + l - s + c2<BR> ax8 = ax0 + l - k + c2<BR> ax9 = ax0 + l + c2<BR> ax10 = (ax1 + ax2) / 2#<BR> ax11 = ax8 + d1 / 10#<BR> ay0 = ap(1)<BR> ay2 = ay0 + d1 / 2#<BR> ay3 = ay0 + c * 3 / 8<BR> ay4 = ay0 + d / 2#<BR> ay5 = ay0 + c / 2#<BR> ay6 = ay0 + r + d1 / 2#<BR> ay7 = ay0 + d1 / 2# - k<BR> ay8 = (ay4 + ay5) / 2#<BR> ay9 = ay2 - d1 / 10#<BR> ccrad = 1.5 * d1<BR> '设置各参数点<BR> Dim p10, p32, p13, p14, p25, p05, p06, p52, p72, p77, _<BR> p70, p82, p80, p90, p97, p62, p02, p108, p79, p119, p1, p2 As Variant<BR> utilObj.CreateTypedArray p10, vbDouble, ax1, ay0, 0<BR> utilObj.CreateTypedArray p32, vbDouble, ax3, ay2, 0<BR> utilObj.CreateTypedArray p13, vbDouble, ax1, ay3, 0<BR> utilObj.CreateTypedArray p14, vbDouble, ax1, ay4, 0<BR> utilObj.CreateTypedArray p25, vbDouble, ax2, ay5, 0<BR> utilObj.CreateTypedArray p05, vbDouble, ax0, ay5, 0<BR> utilObj.CreateTypedArray p06, vbDouble, ax0 + c2, ay6, 0<BR> utilObj.CreateTypedArray p52, vbDouble, ax5, ay2, 0<BR> utilObj.CreateTypedArray p72, vbDouble, ax7, ay2, 0<BR> utilObj.CreateTypedArray p77, vbDouble, ax7, ay7, 0<BR> utilObj.CreateTypedArray p70, vbDouble, ax7, ay0, 0<BR> utilObj.CreateTypedArray p82, vbDouble, ax8, ay2, 0<BR> utilObj.CreateTypedArray p80, vbDouble, ax8, ay0, 0<BR> utilObj.CreateTypedArray p90, vbDouble, ax9, ay0, 0<BR> utilObj.CreateTypedArray p97, vbDouble, ax9, ay7, 0<BR> utilObj.CreateTypedArray p62, vbDouble, ax6, ay2, 0<BR> utilObj.CreateTypedArray p02, vbDouble, ax0, ay2, 0<BR> utilObj.CreateTypedArray p108, vbDouble, ax10, ay8, 0<BR> utilObj.CreateTypedArray p79, vbDouble, ax7, ay9, 0<BR> utilObj.CreateTypedArray p119, vbDouble, ax11, ay9, 0<BR> utilObj.CreateTypedArray p1, vbDouble, ax0 + c2, ay0, 0<BR> utilObj.CreateTypedArray p2, vbDouble, ax0 + c2, ay0 + dw / 2, 0<BR> <BR>
' 生成块
Set blockObj = ThisDrawing.Blocks.Add(ap, mx)<BR> <BR>Dim linea, lineb, linec, lined, linee, linef, lineg, lineh, linei, linej, _<BR>linek, linep, lineq As AcadLine
'绘制螺栓侧视图的一侧各条线段<BR> Set linea = blockObj.AddLine(p10, p14)<BR> Set lineb = blockObj.AddLine(p14, p25)<BR> Set linec = blockObj.AddLine(p25, p05)<BR> Set lined = blockObj.AddLine(p05, ap)<BR> Set linee = blockObj.AddLine(p06, ap)<BR> Set linef = blockObj.AddLine(p32, p02)<BR> Set lineg = blockObj.AddLine(p52, p82)<BR> Set lineh = blockObj.AddLine(p82, p80)<BR> Set linei = blockObj.AddLine(p82, p97)<BR> Set linej = blockObj.AddLine(p97, p90)<BR> Set linek = blockObj.AddLine(p72, p70)<BR> Set linep = blockObj.AddLine(p1, p2)<BR> Set lineq = blockObj.AddLine(p2, p05)<BR> <BR> dist = distance(p32, p10)<BR> pi = 3.1415926536<BR> ang1 = Atn(Sqr(ccrad ^ 2 - (dist / 2#) ^ 2) * 2 / dist)<BR> ang2 = ThisDrawing.Utility.AngleFromXAxis(p32, p10)<BR> ang3 = ang1 + ang2 - 2 * pi<BR> <BR> Dim cenPt As Variant<BR> cenPt = ThisDrawing.Utility.PolarPoint(p32, ang3, ccrad)<BR> angs = ThisDrawing.Utility.AngleFromXAxis(cenPt, p32)<BR> ange = ThisDrawing.Utility.AngleFromXAxis(cenPt, p10)<BR> <BR> Dim arca As AcadArc<BR> Set arca = blockObj.AddArc(cenPt, ccrad, angs, ange)<BR> Dim arcb As AcadArc<BR> <BR> Dim cenPt2 As Variant<BR> '利用 p108, p13, p32 绘制圆弧<BR> cenPt2 = centerPt(p108, p13, p32)<BR> arcb_ra = distance(cenPt2, p108)<BR> arcb_angs = ThisDrawing.Utility.AngleFromXAxis(cenPt2, p108)<BR> arcb_ange = ThisDrawing.Utility.AngleFromXAxis(cenPt2, p32)<BR> <BR> Set arcb = blockObj.AddArc(cenPt2, arcb_ra, arcb_angs, arcb_ange)<BR> <BR> 'arcc<BR> distc = distance(p06, p52)<BR> ang1c = Atn(Sqr(rr ^ 2 - (distc / 2#) ^ 2) * 2 / distc)<BR> ang2c = ThisDrawing.Utility.AngleFromXAxis(p06, p52)<BR> ang3c = ang1c + ang2c - 2 * pi<BR> <BR> Dim cenPt3 As Variant<BR> cenPt3 = ThisDrawing.Utility.PolarPoint(p06, ang3c, rr)<BR> arcc_angs = ThisDrawing.Utility.AngleFromXAxis(cenPt3, p06)<BR> arcc_ange = ThisDrawing.Utility.AngleFromXAxis(cenPt3, p52)<BR> '绘制螺栓侧视图的圆弧<BR> Dim arcc As AcadArc<BR> Set arcc = blockObj.AddArc(cenPt3, rr, arcc_angs, arcc_ange)<BR> <BR> 'color 3<BR> Dim linel, linem As AcadLine<BR> Set linel = blockObj.AddLine(p62, p79)<BR> Set linem = blockObj.AddLine(p79, p119)<BR> linel.Color = 3<BR> linem.Color = 3<BR> '对绘制的螺栓进行镜像<BR> Dim acadent As AcadEntity<BR> For Each acadent In blockObj<BR> acadent.Mirror p10, ap<BR> Next acadent<BR> <BR> <BR>End If
Dim insertPt As Variant<BR> utilObj.CreateTypedArray insertPt, vbDouble, sp(0), sp(1), sp(2)<BR> <BR> <BR> Dim blockRefObj As AcadBlockReference<BR> Set blockRefObj = ThisDrawing.ModelSpace.InsertBlock(insertPt, mx, 1#, 1#, 1#, 0)<BR> <BR> ThisDrawing.Regen acActiveViewport<BR>
ThisDrawing.SetVariable "osmode", sysOSMODE<BR>End Sub
各位大侠,这个是斑竹所提供的螺栓源码中thisdrawing部分,也就是代码的核心部分,我想问一下,
Public Sub m(d1, h, c, d, r, k, s, c2, dw As Double)中,的d1, h, c, d, r, k, s, c2, dw 这些参数分别代表什么?运行可以,但是看不懂啊!请给指点,谢谢啊!
页:
[1]