为什么设置时文字对齐方式时,文字会跑了?
<DIV><BR>Sub labelpnt()<BR> Dim Ent As AcadBlockReference<BR> Dim Height As Double<BR> Dim pickedp1 As Variant<BR> Dim pickedp2 As Variant<BR> Dim OffsetValue As Double<BR> Dim MidPos(0 To 2) As Double<BR> Dim FromPnt, Topnt As Variant<BR> Dim ppt As Variant<BR> Dim NoObj As AcadText<BR> Dim ElevObj As AcadText<BR> Dim line1 As AcadLine<BR> Dim line2 As AcadLine<BR> Dim Group1 As AcadGroup<BR> Dim objgroup(0 To 3) As AcadEntity<BR> <BR> Dim sPnt As Variant<BR> Dim ePnt As Variant<BR>Const pi = 3.1415926<BR> On Error Resume Next<BR> <BR>RETRY:<BR> <BR> Call ThisDrawing.Utility.GetEntity(Ent, pnt, vbCrLf & "选符号...")<BR> If Err Then<BR> Err.Clear<BR> End<BR> End If<BR> <BR> LblLen = 5<BR> Height = 1<BR> OffsetValue = 0.5<BR> <BR> FromPnt = Ent.InsertionPoint<BR> Topnt = ThisDrawing.Utility.GetPoint(FromPnt, "指定标注位置...")<BR> If Err <> 0 Then<BR> Err.Clear<BR> Exit Sub<BR> End If<BR> <BR> Set line1 = ThisDrawing.ModelSpace.AddLine(FromPnt, Topnt)<BR> <BR> If pd(FromPnt, Topnt) = True Then<BR> ppt = ThisDrawing.Utility.PolarPoint(Topnt, pi, LblLen)<BR> Else<BR> ppt = ThisDrawing.Utility.PolarPoint(Topnt, 0, LblLen)<BR> End If<BR> <BR> Set line2 = ThisDrawing.ModelSpace.AddLine(Topnt, ppt)<BR> <BR> sPnt = line2.StartPoint<BR> ePnt = line2.EndPoint<BR> <BR> '''Ï中点坐标<BR> MidPos(0) = (sPnt(0) + ePnt(0)) / 2<BR> MidPos(1) = (sPnt(1) + ePnt(1)) / 2<BR> MidPos(2) = 0<BR> <BR> '''文字注记位置</DIV><DIV> pickedp1 = ThisDrawing.Utility.PolarPoint(MidPos, pi / 2, OffsetValue)<BR> pickedp2 = ThisDrawing.Utility.PolarPoint(MidPos, 0 - pi / 2, Height + OffsetValue)<BR> <BR> '''标注文字</DIV>
<DIV> Set NoObj = ThisDrawing.ModelSpace.AddText("JS121", pickedp1, Height)</DIV>
<DIV> </DIV>
<DIV><FONT color=#f70909>'''以下这句总不对</FONT></DIV>
<DIV><BR><FONT color=#f70909> NoObj.Alignment = acAlignmentCenter<BR></FONT> <BR> '''文字<BR> Set ElevObj = ThisDrawing.ModelSpace.AddText("2.12", pickedp2, Height)<BR> <FONT color=#f73809> NoObj.Alignment = acAlignmentCenter<BR></FONT> <BR> '''¶ÔÏó±à×é<BR> Set objgroup(0) = line1<BR> Set objgroup(1) = line2<BR> Set objgroup(2) = NoObj<BR> Set objgroup(3) = ElevObj<BR> Set Group1 = ThisDrawing.Groups.Add("*")<BR> Group1.AppendItems objgroup</DIV>
<DIV> </DIV>
<DIV>GoTo RETRY<BR> <BR>End Sub</DIV>
<DIV> </DIV>
<DIV>Function pd(p1 As Variant, p2 As Variant) As Boolean<BR> If p1(0) > p2(0) Then<BR> pd = True<BR> Else<BR> pd = False<BR> End If<BR>End Function</DIV>
<DIV> </DIV>
<DIV>以上红色语句不知为何不能设置居中,加入居中语句后文字会跑到老远的地方,这是为什么?请指教</DIV> 在另外一贴我已经回复了,你去看一下. <FONT color=#f73809>NoObj.Alignment = acAlignmentCenter '后加下语句</FONT>
<FONT color=#f73809>NoObj</FONT>.TextAlignmentPoint = pickedp2 我试出来了,谢谢大家。
页:
[1]