LLLANHAN 发表于 2009-9-1 21:29:00

请教用sendcommand命令圆角问题

<p>请教各位高人帮助</p><p>我想实现圆弧和线段的圆角处理,引用论坛里牛人sendcommand代码,可以实现功能,但是倒出来的圆角位置不对,请高人,帮忙啊。。。</p><p></p><p>千恩万谢。。。。</p><p>代码如下,vb中写的。代码中红色这一段没搞清楚什么意思。但是程序是通的,而且的确倒了圆角,只是结果非我所要求的。如何改???</p><p>AcadApp.ActiveDocument.SendCommand "_fillet" &amp; vbCr &amp; "r" &amp; vbCr &amp; "5" &amp; vbCr &amp; "t" &amp; vbCr &amp; "t" &amp; vbCr &amp;<font color="#ff0000"> "(handent " &amp; Chr(34) &amp; lineObj1.Handle &amp; Chr(34) &amp; ")" &amp; vbCr &amp; "(handent " &amp; Chr(34) &amp; arcNsObj.Handle &amp; Chr(34) &amp; ")" </font>&amp; vbCr</p>

mccad 发表于 2009-9-2 06:23:00

<p>AutoCAD的圆角命令除是指定图元外,还与选择的点位置有关,如果选到的点是靠直线的起点,就优先做起点端的圆角,如果选的是靠终点,则优先做终点端的圆角,实际上你自己在AutoCAD中操作就知道,所以它是与选择的点有关。</p><p>你想做圆角,那就得知道你所需要圆角处是靠线的哪一端,在程序中给定的点就得用靠哪端的点,而不是直接给个图元或随便给个点的行。</p>

mccad 发表于 2009-9-1 21:45:00

<a href="http://www.mjtd.com/Develop/ArticleShow.asp?ArticleID=49">http://www.mjtd.com/Develop/ArticleShow.asp?ArticleID=49</a>

LLLANHAN 发表于 2009-9-1 21:46:00

LLLANHAN 发表于 2009-9-1 21:59:00

您提示的是vba中的转换,看不懂

本帖最后由 作者 于 2009-9-1 22:48:08 编辑 <br /><br /> <p>您提示的是vba中的转换,看不懂</p><p>ThisDrawing.Utility.GetEntity entObj, Pnt, "选择图元:" 这句代码,不知道在vb&nbsp; 中怎么对应啊。。。急。。。。。</p><p>这个看懂了。有个新的问题在下面</p>

mccad 发表于 2009-9-1 22:07:00

ThisDrawing=AcadApp.ActiveDocument

LLLANHAN 发表于 2009-9-1 22:47:00

<p>认证的学习了一下您的代码,有一点搞不清楚</p><p>&nbsp;&nbsp;det2 = GetDoubleEntTable(entObj2, Pnt2) 函数,这个pnt2是什么东西,是图元entObj2上的点吗??</p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;det2 = GetDoubleEntTable(entObj2, Pnt2)</p><p>这个det2 的转换,还是有点不理解,我的程序如下,麻烦高人看看,如何修改</p><p>我现在想做的是,不用选择图元,而是直接引用两个图元,lineObj1,和arcNsObj进行sendcommand 圆角命令,代码如下,结果还是和原来一样。</p><p></p><p>Dim Pnt1 As Variant</p><p>Dim det1 As String<br/>det1 = axEnt2lspEnt(lineObj1)</p><p>Dim Pnt2 As Variant</p><p>Dim det2 As String<br/>det2 = GetDoubleEntTable(arcNsObj, startPointNs) 'startpointNs 是arcNsObj图元的起点</p><p><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 &amp; vbCr</p><p>执行最后一句代码时,监视到</p><p>det1="(handent "89")"</p><p>det2="(list(handent "88")(list&nbsp; 25 0 0))"</p>

LLLANHAN 发表于 2009-9-1 23:02:00

<p>这个是我用vb 编写的程序的完整代码,套用了版主的一些代码,呵呵,初学乍练,请大家拍砖帮助修改。</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><br/>''''''''''''''''''''''''''''''''''''''''''''''''''''Addarc</p><p>Dim arcNxObj As Object<br/>Dim arcNsObj As Object</p><p></p><p>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>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</p><p>Dim det1 As String<br/>det1 = axEnt2lspEnt(lineObj1)</p><p>Dim Pnt2 As Variant</p><p>Dim det2 As String<br/>det2 = GetDoubleEntTable(arcNsObj, startPointNs)</p><p><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 &amp; vbCr<br/><br/>'AcadApp.Quit</p><p>'Set oDocument = Nothing<br/>'Set AcadApp = Nothing</p><p>End Sub</p><p><br/>Private Sub Form_Load()</p><p>On Error Resume Next<br/>Set acadpp = GetObject(, "AutoCAD.application")<br/>&nbsp;&nbsp;&nbsp; <br/>If Err Then<br/>&nbsp;&nbsp;&nbsp; Err.Clear<br/>&nbsp;&nbsp;&nbsp; Set AcadApp = CreateObject("AutoCAD.application")<br/>&nbsp;&nbsp;&nbsp; If Err Then<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MsgBox ("不能运行autocad2004,请检查")<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Exit Sub<br/>&nbsp;&nbsp;&nbsp; End If<br/>End If<br/>AcadApp.Visible = True<br/>'Set oDocument = AcadApp.ActiveDocument<br/>'AcadApp.ActiveDocument.ActiveViewport.GridOn = True<br/>'AcadApp.ActiveDocument.ActiveViewport = AcadApp.ActiveDocument.ActiveViewport</p><p></p><p><br/></p><p><br/>End Sub</p>

雪山飞狐_lzh 发表于 2009-9-1 23:40:00

这个倒圆角应该是可以算出来的?

LLLANHAN 发表于 2009-9-2 16:26:00

<p>只能回去再试试了,希望成功.</p><p>感谢mccad的关注和支持...</p>
页: [1] 2
查看完整版本: 请教用sendcommand命令圆角问题