如何将选择的pline用mline重绘
Sub tt()'本程序的作用是选择一个pline线。然后用mline线重新绘制(原pline保留)
'mline 对正样式是“无”都设置好了,直接调用即可
Dim px(200) As Double '处理N个点(不定)<BR> Dim py(200) As Double<BR> 'Dim center(211) As Double<BR> Dim ent As Object<BR> ' let the user select a block.<BR> '<BR> If (flgPickNested = True) Then<BR> Debug.Print "错误"<BR> Exit Sub<BR> Else<BR> Dim pt As Variant<BR> ThisDrawing.Utility.GetEntity ent, pt<BR> End If<BR> <BR> var = ent.Coordinates<BR> retCoord = ent.Coordinates<BR> k = (UBound(retCoord) + 1) / 2 '记录pline顶点个数
<BR> For i = 0 To UBound(retCoord) Step 2<BR> px(i / 2) = retCoord(i)<BR> py(i / 2) = retCoord(i)
Next i<BR> ReDim center(2 * (k - 1) + 1) As Double<BR> <BR> For i = 0 To k - 1<BR> center(i) = px(i)<BR> center(i + 1) = py(i)<BR> 'center(i + 2) = 0<BR> MsgBox center(i) & " =" & center(i + 1)<BR> Next i<BR> Dim lll As AcadMLine<BR> <BR> Set lll = ThisDrawing.ModelSpace.AddMLine(center)<BR> ZoomAll<BR> <BR>End Sub
程序始终出错
请各位大虾帮忙调试 Sub tt()
'±¾³ÌÐòµÄ×÷ÓÃÊÇÑ¡ÔñÒ»¸öplineÏß¡£È»ºóÓÃmlineÏßÖØлæÖÆ£¨Ô­pline±£Áô£©
'mline ¶ÔÕýÑùʽÊÇ¡°ÎÞ¡±¶¼ÉèÖúÃÁË£¬Ö±½Óµ÷Óü´¿É
Dim px() As Double '´¦ÀíN¸öµã£¨²»¶¨£©<BR> Dim py() As Double<BR> Dim center() As Double<BR> Dim ent As Object<BR> ' let the user select a block.<BR> '<BR> If (flgPickNested = True) Then<BR> Debug.Print "´íÎó"<BR> Exit Sub<BR> Else<BR> Dim pt As Variant<BR> ThisDrawing.Utility.GetEntity ent, pt<BR> End If<BR> <BR> var = ent.Coordinates<BR> retCoord = ent.Coordinates<BR> k = (UBound(retCoord) + 1) / 2 '¼Ç¼pline¶¥µã¸öÊý
ReDim px(k)<BR> ReDim py(k)<BR> For i = 0 To UBound(retCoord) Step 2<BR> px(i / 2) = retCoord(i)<BR> py(i / 2) = retCoord(i + 1)<BR> Next i<BR> ReDim center(3 * k - 1)<BR> <BR> For i = 0 To k - 1<BR> center(3 * i) = px(i)<BR> center(3 * i + 1) = py(i)<BR> center(3 * i + 2) = 0#<BR> MsgBox center(3 * i) & ", " & center(3 * i + 1) & ", " & center(3 * i + 2)<BR> Next i<BR> Dim lll As AcadMLine<BR> <BR> Set lll = ThisDrawing.ModelSpace.AddMLine(center)<BR> ZoomAll<BR> <BR>End Sub 对以上程序我做了一点改进
只要执行有误,那么就是在2,和3之间的事情
Sub tt()
Do While 1<BR> Dim ent As Object<BR> If (flgPickNested = True) Then<BR> Debug.Print "错误"<BR> Exit Sub<BR> Else<BR> Dim pt As Variant<BR> ThisDrawing.Utility.GetEntity ent, pt<BR> End If<BR> <BR> var = ent.Coordinates<BR> retCoord = ent.Coordinates<BR> k = (UBound(retCoord) + 1) / 3 '记录pline顶点个数<BR> ReDim px(k - 1) As Double<BR> ReDim py(k - 1) As Double
For i = 0 To UBound(retCoord) Step 3<BR> px(i / 3) = retCoord(i)<BR> py(i / 3) = retCoord(i + 1)
Next i<BR> Dim m As Integer<BR> Dim n As Integer<BR> m = 0<BR> n = 0<BR> ReDim Center(3 * (k - 1) + 2) As Double<BR> For i = 0 To k - 1
Center(i * 3) = px(i)<BR> Center(i * 3 + 1) = py(i)<BR> Center(i * 3 + 2) = 0<BR> 'MsgBox px(i) & "*" & py(i)<BR> Next i<BR> <BR> <BR> 'For i = 0 To 2 * (k - 1) + 1<BR> 'MsgBox Center(i)<BR> 'Next i<BR> Dim lwp As AcadMLine<BR> <BR> Set lwp = ThisDrawing.ModelSpace.AddMLine(Center)<BR> <BR> lwp.Update<BR> <BR> picked = True<BR> <BR>Loop<BR> <BR>ErrHandle:<BR> <BR>End Sub<BR>新的问题又来了,我要在自动绘制前把mline的线间距调整一下。
如何用程序实现 查查系统变量CMLJUST,CMLSCALE和CMLSTYLE
页:
[1]