乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 73|回复: 5

[编程交流] 根据相邻对象对齐文本

[复制链接]

14

主题

29

帖子

15

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
70
发表于 2022-7-6 14:52:03 | 显示全部楼层 |阅读模式
大家好,
 
是否有一种根据相邻行/对象的对齐方式自动对齐文本的方法。
 
谢谢和问候,
普里扬卡
回复

使用道具 举报

26

主题

1495

帖子

20

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
118
发表于 2022-7-6 15:04:16 | 显示全部楼层
根据实体类型,为什么不在创建文本之前使用UCS-大卫
回复

使用道具 举报

0

主题

132

帖子

198

银币

限制会员

铜币
-21
发表于 2022-7-6 15:19:07 | 显示全部楼层
这是我不久前写的。请注意,这些单位是公制的。
 
http://mechcad-insider.blogspot.com/2009/03/get-in-align.html
回复

使用道具 举报

4

主题

940

帖子

961

银币

初来乍到

Rank: 1

铜币
12
发表于 2022-7-6 15:28:16 | 显示全部楼层
寻找塔龙。非常慷慨的ASMI的lsp
http://www.asmitools.com/Files/Programs.html
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 15:47:58 | 显示全部楼层
 
^^Lisp程序
回复

使用道具 举报

14

主题

29

帖子

15

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
70
发表于 2022-7-6 15:58:29 | 显示全部楼层
谢谢大家的帮助。。
 
最后,我得出了用数学公式收集线的角度,即。
 
轴承=tan(逆)=y2-y1/x2-x1
 
并将此方向角提供给textobject。
 
最终,我想检索长度,创建一个长度和线条旋转相同的文本
 
因此,结果是这样的:
 
  1. [b][font=Times New Roman][/font][/b]
  2. [font=Times New Roman][size=3][b]‘Collects Length, Creates a text of its length at the midpoint of the line at the same rotation as line[/b]
  3. Private Sub cmdlength_Click()
  4.                      
  5. On Error Resume Next
  6. [b]‘Collects Length[/b]
  7. Dim SOS As AcadSelectionSet
  8. Dim objSS As AcadSelectionSet
  9. Dim intCode(0) As Integer
  10. Dim varData(0) As Variant
  11. Dim objEnt As AcadEntity
  12. Dim entLine As AcadLine
  13. Dim entPoly As AcadPolyline
  14. Dim entLWPoly As AcadLWPolyline
  15. Dim lenstring As String
  16. Dim coordstart As Variant
  17. Dim basepoint(0 To 2) As Double
  18. Dim col As New AcadAcCmColor
  19. Call col.SetRGB(127, 0, 0)
  20. a = 1
  21. For Each SOS In ThisDrawing.SelectionSets
  22.     If SOS.Name = "MySS" Then
  23.        ThisDrawing.SelectionSets("MySS").Delete
  24.     Exit For
  25.     End If
  26. Next
  27. intCode(0) = 0: varData(0) = "LINE,POLYLINE,LWPOLYLINE"
  28. ThisDrawing.SelectionSets.Add ("MySS")
  29. Set objSS = ThisDrawing.SelectionSets("MySS")
  30. objSS.SelectOnScreen intCode, varData
  31. If objSS.Count < 1 Then
  32.     MsgBox "No lines and polylines selected!"
  33. Exit Sub
  34. End If
  35. Dim endPoint As Variant
  36. For Each objEnt In objSS
  37. Select Case objEnt.ObjectName
  38.     Case "AcDbLine"
  39.        Set entLine = objEnt
  40.        endPoint = entLine.endPoint
  41.            ' MsgBox endPoint
  42.        lenstring = Round(entLine.Length)
  43.       
  44.        '  MsgBox lenstring
  45. '     Case "AcDb2dPolyline"
  46. '        Set entPoly = objEnt
  47. '        coord = entPoly.Coordinate(0)
  48. '        lenstring = Round(entPoly.Length)
  49. '       MsgBox lenstring
  50.          
  51.     Case "AcDbPolyline"
  52.        Set entLWPoly = objEnt
  53.       ' endPoint = entLine.endPoint
  54.       coordend = entLWPoly.Coordinate(1)
  55.       coordstart = entLWPoly.Coordinate(0)
  56.       
  57.       x1 = coordstart(0)
  58.       y1 = coordstart(1)
  59.    
  60.       x2 = coordend(0)
  61.       y2 = coordend(1)
  62.       
  63.          'MsgBox x1 & "," & y1
  64.       
  65.       midpoint = (coordend(0) + coordstart(0)) / 2 & " , " & (coordend(1) + coordstart(1)) / 2
  66.    
  67.          ' entLWPoly.Rotate midpoint, rotationAngle
  68.      lenstring = Round(entLWPoly.Length)
  69.      
  70.       x = (coordend(0) + coordstart(0)) / 2
  71.       y = (coordend(1) + coordstart(1)) / 2
  72.       
  73. [b]‘Collects rotation angle of line[/b]
  74.       bearing = (y2 - y1) / (x2 - x1)
  75.       bearing = Atn(bearing)
  76.       
  77.     End Select
  78.    
  79.    Dim textobj As AcadText
  80.    Dim textString As String
  81.    Dim insertionPoint(0 To 2) As Double
  82.    Dim height As Double
  83.    
  84.    ' Define the text object
  85.    textString = lenstring
  86.    insertionPoint(0) = x: insertionPoint(1) = y + 15: insertionPoint(2) = 0
  87.    height = 22
  88.    
  89.    ' Create the text object in model space
  90.    Set textobj = ThisDrawing.ModelSpace.AddText(textString & "m", insertionPoint, height)
  91.    textobj.Rotation = bearing
  92. '    If bearing = 0 Then
  93. '    textobj.Rotation = 0
  94. '    End If
  95.    textobj.TrueColor = col
  96.    textobj.StyleName = "ArialBold"
  97.   
  98.   Next
  99. [/size][/font]

 
 
我仍然有一个问题,,,我在VB表单中创建了所有这些,在这个表单中有许多其他用于各种目的的按钮。。。为了访问它,我使用了。lsp
 
 
 
  1. (vl-load-com)(defun C:APID()(vl-vbarun
  2. "Path\\Projectdvb!initialize"))

 
 
但是,我必须硬编码这条路。。是否可以创建一个DLL或VB表单的一些可执行文件
 
谢谢和问候,
普里扬卡
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-4 21:27 , Processed in 0.474404 second(s), 64 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表