请教VB二次开发CAD中插入多个单行文字操作!
下面代码能实现在指定位置插入一个单行文字的功能,请问我要在一个CAD文件中的多个位置插入不同内容的当行文字该如何实现?这一步很重要,希望高手们能够帮我解答,先谢谢大家了!...
下面代码能实现在指定位置插入一个单行文字的功能,请问我要在一个CAD文件中的多个位置插入不同内容的当行文字该如何实现?这一步很重要,希望高手们能够帮我解答,先谢谢大家了!
Private Sub Command1_Click()
Dim styobj1 As AcadTextStyle
Dim typeFace As String
Dim Bold As Boolean
Dim Italic As Boolean
Dim charSet As Long
Dim PitchandFamily As Long
Set styobj1 = acadapp.ActiveDocument.TextStyles.Add("黑体")
typeFace = "黑体"
Italic = False
Bold = True
charSet = 1
PitchandFamily = 1 Or 16
styobj1.SetFont typeFace, Bold, Italic, charSet, PitchandFamily
styobj1.width = 0.75
Dim textobj As AcadText
Dim textstring As String
Dim insertionpoint(0 To 2) As Double
Dim height As Double
Dim width As Double
Dim returnPnt As Variant
textstring = Right((Left(ActiveDocument.Name, Len(ActiveDocument.Name) - 4)), Len(Left(ActiveDocument.Name, Len(ActiveDocument.Name) - 4)) - 3)
height = 3
returnPnt1 = ActiveDocument.Utility.GetPoint(, "指定文字插入点: ")
returnPnt2 = ActiveDocument.Utility.GetPoint(, "指定下一个文字插入点: ")
insertionpoint(0) = (returnPnt1(0) + returnPnt2(0)) / 2: insertionpoint(1) = (returnPnt1(1) + returnPnt2(1)) / 2: insertionpoint(2) = (returnPnt1(2) + returnPnt2(2)) / 2
acadapp.ActiveDocument.ActiveTextStyle = styobj1
Set textobj = acadapp.ActiveDocument.PaperSpace.AddText(textstring, insertionpoint, height)
textobj.Alignment = acAlignmentMiddleCenter
textobj.TextAlignmentPoint = insertionpoint
textobj.Update
End Sub 展开
Private Sub Command1_Click()
Dim styobj1 As AcadTextStyle
Dim typeFace As String
Dim Bold As Boolean
Dim Italic As Boolean
Dim charSet As Long
Dim PitchandFamily As Long
Set styobj1 = acadapp.ActiveDocument.TextStyles.Add("黑体")
typeFace = "黑体"
Italic = False
Bold = True
charSet = 1
PitchandFamily = 1 Or 16
styobj1.SetFont typeFace, Bold, Italic, charSet, PitchandFamily
styobj1.width = 0.75
Dim textobj As AcadText
Dim textstring As String
Dim insertionpoint(0 To 2) As Double
Dim height As Double
Dim width As Double
Dim returnPnt As Variant
textstring = Right((Left(ActiveDocument.Name, Len(ActiveDocument.Name) - 4)), Len(Left(ActiveDocument.Name, Len(ActiveDocument.Name) - 4)) - 3)
height = 3
returnPnt1 = ActiveDocument.Utility.GetPoint(, "指定文字插入点: ")
returnPnt2 = ActiveDocument.Utility.GetPoint(, "指定下一个文字插入点: ")
insertionpoint(0) = (returnPnt1(0) + returnPnt2(0)) / 2: insertionpoint(1) = (returnPnt1(1) + returnPnt2(1)) / 2: insertionpoint(2) = (returnPnt1(2) + returnPnt2(2)) / 2
acadapp.ActiveDocument.ActiveTextStyle = styobj1
Set textobj = acadapp.ActiveDocument.PaperSpace.AddText(textstring, insertionpoint, height)
textobj.Alignment = acAlignmentMiddleCenter
textobj.TextAlignmentPoint = insertionpoint
textobj.Update
End Sub 展开
- 你的回答被采纳后将获得:
- 系统奖励15(财富值+成长值)+难题奖励10(财富值+成长值)+提问者悬赏5(财富值+成长值)
3个回答
推荐于2017-09-18
展开全部
把这一段i=0Doi=i+1。。。LoopUntili=Val(InputBox("插入字符数","",4))Ifi=0Theni=4改成如下TextLength=Val(InputBox("插入字符数","",4))fori=0toTextLength.nexti
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
太高级了,不懂
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |