12qq21 发表于 2009-9-3 12:47:00

mccad发表于2009-9-2 6:23:00static/image/common/back.gifAutoCAD的圆角命令除是指定图元外,还与选择的点位置有关,如果选到的点是靠直线的起点,就优先做起点端的圆角,如果选的是靠终点,则优先做终点端的圆角,实际上你自己在AutoCAD中操作就知道,

<p></p>请问mccad,怎么在程序中给定个点来表示所要的圆角靠近哪个端?谢谢!

LLLANHAN 发表于 2009-9-4 11:51:00

<p>我已经试验成功了。。。感谢高人的指点,对于那个点的设定,我的理解是,点是用来确定,圆角倒的方向的,所以,点只要设定在要倒圆角的内部就可以了。</p><p>整个的程序代码如下:供大家指证。。。</p><p>Public AcadApp As AcadApplication<br/>'Public oDocument As Object<br/>Dim centerPoint(0 To 2) As Double</p><p>Public Function axEnt2lspEnt(entObj As AcadEntity) As String</p><p><br/>Dim entHandle As String<br/>entHandle = entObj.Handle<br/>axEnt2lspEnt = "(handent " &amp; Chr(34) &amp; entHandle &amp; Chr(34) &amp; ")"<br/>End Function</p><p><br/>Public Function GetDoubleEntTable(entObj As AcadEntity, Pnt As Variant) As String<br/>&nbsp;&nbsp;&nbsp; Dim entHandle As String<br/>&nbsp;&nbsp;&nbsp; entHandle = entObj.Handle<br/>&nbsp;&nbsp;&nbsp; GetDoubleEntTable = "(list(handent " &amp; Chr(34) &amp; entHandle &amp; Chr(34) &amp; ")(list " &amp; Str(Pnt(0)) &amp; Str(Pnt(1)) &amp; Str(Pnt(2)) &amp; "))"<br/>&nbsp;End Function</p><p>Private Sub Command1_Click()</p><p></p><p>''''''''''''''''''''''''''''''''''''''''''''''''''''Addarc</p><p>Dim arcNxObj As Object<br/>Dim arcNsObj As Object</p><p><br/>Dim radiusARCNx As Double<br/>Dim startAngleInDegreeN As Double<br/>Dim endAngleInDegreeN As Double<br/>Dim startAngleInRadianN As Double<br/>Dim endAngleInRadianN As Double</p><p><br/>'Dim blockObj As AcadBlock<br/>'Set blockObj = AcadApp.ActiveDocument.SelectionSets.Add("FWw")</p><p><br/>radiusARCNx = 15#</p><p>startAngleInDegreeN = 0#<br/>endAngleInDegreeN = 45#</p><p>startAngleInRadianN = startAngleInDegreeN * 3.141592 / 180#<br/>endAngleInRadianN = endAngleInDegreeN * 3.141592 / 180#</p><p>Set arcNxObj = AcadApp.ActiveDocument.ModelSpace.AddArc(centerPoint, radiusARCNx, startAngleInRadianN, endAngleInRadianN)</p><p>Dim arcNs As Object<br/>Dim radiusARCNs As Double<br/>radiusARCNs = 25#</p><p>Set arcNsObj = AcadApp.ActiveDocument.ModelSpace.AddArc(centerPoint, radiusARCNs, startAngleInRadianN, endAngleInRadianN)<br/>Dim endPointNx As Variant<br/>Dim startPointNx As Variant<br/>Dim endPointNs As Variant<br/>Dim startPointNs As Variant</p><p><br/>arcNsObj.Color = acRed</p><p>startPointNx = arcNxObj.StartPoint<br/>endPointNx = arcNxObj.EndPoint<br/>endPointNs = arcNsObj.EndPoint<br/>startPointNs = arcNsObj.StartPoint<br/>Dim lineObj1 As Object<br/>Dim lineObj2 As Object</p><p>Set lineObj1 = AcadApp.ActiveDocument.ModelSpace.AddLine(startPointNx, startPointNs)<br/>Set lineObj2 = AcadApp.ActiveDocument.ModelSpace.AddLine(endPointNx, endPointNs)</p><p>ZoomExtents</p><p>'''''''''''''''''''''''想实现fillet 直线与圆弧的圆角功能<br/>Dim Pnt1 As Variant<br/>Dim det1 As String<br/>Dim Pnt2 As Variant<br/>Dim det2 As String<br/>det1 = axEnt2lspEnt(arcNsObj)<br/>Pnt2 = lineObj1.EndPoint<br/>Pnt2(0) = Pnt2(0) - 1<br/>det2 = GetDoubleEntTable(lineObj1, Pnt2)<br/>AcadApp.ActiveDocument.SendCommand "_fillet" &amp; vbCr &amp; "r" &amp; vbCr &amp; "2" &amp; vbCr &amp; "t" &amp; vbCr &amp; "t" &amp; vbCr &amp; det1 &amp; vbCr &amp; vbCr &amp; det2 &amp; vbCr</p><p>Dim DaoJiao(4) As AcadEntity</p><p><br/>Set DaoJiao(0) = AcadApp.ActiveDocument.ModelSpace(AcadApp.ActiveDocument.ModelSpace.Count - 1)</p><p><br/>det1 = axEnt2lspEnt(arcNsObj)<br/>Pnt2 = lineObj2.EndPoint<br/>Pnt2(0) = Pnt2(0) - 1<br/>det2 = GetDoubleEntTable(lineObj2, Pnt2)<br/>AcadApp.ActiveDocument.SendCommand "_fillet" &amp; vbCr &amp; "r" &amp; vbCr &amp; "2" &amp; vbCr &amp; "t" &amp; vbCr &amp; "t" &amp; vbCr &amp; det1 &amp; vbCr &amp; vbCr &amp; det2 &amp; vbCr<br/>Set DaoJiao(1) = AcadApp.ActiveDocument.ModelSpace(AcadApp.ActiveDocument.ModelSpace.Count - 1)</p><p><br/>det1 = axEnt2lspEnt(arcNxObj)<br/>Pnt2 = lineObj2.EndPoint<br/>arcNxObj.Color = acGreen<br/>Pnt2(0) = Pnt2(0) + 1<br/>det2 = GetDoubleEntTable(lineObj2, Pnt2)<br/>AcadApp.ActiveDocument.SendCommand "_fillet" &amp; vbCr &amp; "r" &amp; vbCr &amp; "2" &amp; vbCr &amp; "t" &amp; vbCr &amp; "t" &amp; vbCr &amp; det1 &amp; vbCr &amp; vbCr &amp; det2 &amp; vbCr<br/>Set DaoJiao(2) = AcadApp.ActiveDocument.ModelSpace(AcadApp.ActiveDocument.ModelSpace.Count - 1)</p><p><br/>det1 = axEnt2lspEnt(arcNxObj)<br/>Pnt2 = lineObj1.EndPoint<br/>arcNxObj.Color = acGreen</p><p>Pnt2(0) = Pnt2(0) + 1<br/>det2 = GetDoubleEntTable(lineObj1, Pnt2)<br/>AcadApp.ActiveDocument.SendCommand "_fillet" &amp; vbCr &amp; "r" &amp; vbCr &amp; "2" &amp; vbCr &amp; "t" &amp; vbCr &amp; "t" &amp; vbCr &amp; det1 &amp; vbCr &amp; vbCr &amp; det2 &amp; vbCr<br/>Set DaoJiao(3) = AcadApp.ActiveDocument.ModelSpace(AcadApp.ActiveDocument.ModelSpace.Count - 1)</p><p></p><p>Dim rotationAngle As Double<br/>rotationAngle = 0.7853981 * 1.5 ' 45 degrees</p><p><br/>ReDim ssobjs(0 To AcadApp.ActiveDocument.ModelSpace.Count - 1) As AcadEntity<br/>Dim I As Integer<br/>For I = 0 To AcadApp.ActiveDocument.ModelSpace.Count - 1<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; Set ssobjs(I) = AcadApp.ActiveDocument.ModelSpace.Item(I)</p><p>&nbsp;&nbsp;&nbsp; ssobjs(I).Rotate centerPoint, rotationAngle<br/>Next<br/>&nbsp;&nbsp; ZoomExtents<br/>&nbsp;</p><p>'Set oDocument = Nothing<br/>'Set AcadApp = Nothing</p><p>End Sub</p>

LLLANHAN 发表于 2009-9-4 11:58:00

LLLANHAN 发表于 2009-9-4 12:03:00

<p>请教高人有一个新的问题,</p><p>我想将所有的图元都加入一个块,然后用这个块进行阵列,因为,放在集中,集无法阵列</p><p>现在已经知道了,圆弧和线在创建时,就再块中创建,但是倒圆角出来的是个圆弧,由于是用sendcommand出来的,如何再加入已有的块中。</p><p>blockobj中该如何加入已存在的图元?????</p>

mccad 发表于 2009-9-4 12:16:00

不一定用到块吧。你可以每个图元单独进行阵列,写成一个函数就可以。

LLLANHAN 发表于 2009-9-4 12:31:00

<p>我就担心每一个图元进行阵列,就要多一个阵列图元。</p><p>我担心阵列完,图元太多了。</p><p></p>

rekygj 发表于 2011-6-17 22:29:24

学习了,正在研究

页: 1 [2]
查看完整版本: 请教用sendcommand命令圆角问题