请教用sendcommand命令圆角问题
<p>请教各位高人帮助</p><p>我想实现圆弧和线段的圆角处理,引用论坛里牛人sendcommand代码,可以实现功能,但是倒出来的圆角位置不对,请高人,帮忙啊。。。</p><p></p><p>千恩万谢。。。。</p><p>代码如下,vb中写的。代码中红色这一段没搞清楚什么意思。但是程序是通的,而且的确倒了圆角,只是结果非我所要求的。如何改???</p><p>AcadApp.ActiveDocument.SendCommand "_fillet" & vbCr & "r" & vbCr & "5" & vbCr & "t" & vbCr & "t" & vbCr &<font color="#ff0000"> "(handent " & Chr(34) & lineObj1.Handle & Chr(34) & ")" & vbCr & "(handent " & Chr(34) & arcNsObj.Handle & Chr(34) & ")" </font>& vbCr</p> <p>AutoCAD的圆角命令除是指定图元外,还与选择的点位置有关,如果选到的点是靠直线的起点,就优先做起点端的圆角,如果选的是靠终点,则优先做终点端的圆角,实际上你自己在AutoCAD中操作就知道,所以它是与选择的点有关。</p><p>你想做圆角,那就得知道你所需要圆角处是靠线的哪一端,在程序中给定的点就得用靠哪端的点,而不是直接给个图元或随便给个点的行。</p> <a href="http://www.mjtd.com/Develop/ArticleShow.asp?ArticleID=49">http://www.mjtd.com/Develop/ArticleShow.asp?ArticleID=49</a>您提示的是vba中的转换,看不懂
本帖最后由 作者 于 2009-9-1 22:48:08 编辑 <br /><br /> <p>您提示的是vba中的转换,看不懂</p><p>ThisDrawing.Utility.GetEntity entObj, Pnt, "选择图元:" 这句代码,不知道在vb 中怎么对应啊。。。急。。。。。</p><p>这个看懂了。有个新的问题在下面</p> ThisDrawing=AcadApp.ActiveDocument <p>认证的学习了一下您的代码,有一点搞不清楚</p><p> det2 = GetDoubleEntTable(entObj2, Pnt2) 函数,这个pnt2是什么东西,是图元entObj2上的点吗??</p><p> 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" & vbCr & "r" & vbCr & "2" & vbCr & "t" & vbCr & "t" & vbCr & det1 & vbCr & vbCr & det2 & vbCr & vbCr</p><p>执行最后一句代码时,监视到</p><p>det1="(handent "89")"</p><p>det2="(list(handent "88")(list 25 0 0))"</p> <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 " & Chr(34) & entHandle & Chr(34) & ")"<br/>End Function</p><p><br/>Public Function GetDoubleEntTable(entObj As AcadEntity, Pnt As Variant) As String<br/> Dim entHandle As String<br/> entHandle = entObj.Handle<br/> GetDoubleEntTable = "(list(handent " & Chr(34) & entHandle & Chr(34) & ")(list " & Str(Pnt(0)) & Str(Pnt(1)) & Str(Pnt(2)) & "))"<br/> 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" & vbCr & "r" & vbCr & "2" & vbCr & "t" & vbCr & "t" & vbCr & det1 & vbCr & vbCr & det2 & vbCr & 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/> <br/>If Err Then<br/> Err.Clear<br/> Set AcadApp = CreateObject("AutoCAD.application")<br/> If Err Then<br/> MsgBox ("不能运行autocad2004,请检查")<br/> Exit Sub<br/> 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> 这个倒圆角应该是可以算出来的? <p>只能回去再试试了,希望成功.</p><p>感谢mccad的关注和支持...</p>
页:
[1]
2