明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 47|回复: 2

[OpenDCL] 请大佬看下这个调整文字位置问题

[复制链接]
发表于 昨天 16:57 | 显示全部楼层 |阅读模式
我用LISP写的调整文字间距,用这个(vla-put-insertionpoint obj (vlax-3d-point new-pt))更新文字新的坐标位置,当文字是左对齐时没问题,其他对齐方式时不起作用,是什么原因呢,用什么办法解决。
回复

使用道具 举报

发表于 昨天 20:01 | 显示全部楼层
  1. (defun MoveTextProper (obj pt)
  2.   (setq pt (vlax-3d-point pt))

  3.   (cond
  4.     ;; 单行文字
  5.     ((= (vla-get-ObjectName obj) "AcDbText")
  6.      (setq justify (vla-get-Justify obj))
  7.      (if (= justify 0)
  8.        (vla-put-InsertionPoint obj pt)
  9.        (vla-put-AlignmentPoint obj pt)
  10.      )
  11.     )

  12.     ;; 多行文字
  13.     ((= (vla-get-ObjectName obj) "AcDbMText")
  14.      (vla-put-InsertionPoint obj pt)
  15.     )
  16.   )
  17. )
回复 支持 反对

使用道具 举报

发表于 昨天 20:03 | 显示全部楼层
  1. (defun update-text-position-safe (obj new-pt / alignment)
  2.   (setq alignment (vla-get-Alignment obj))
  3.   
  4.   (if (= alignment acAlignmentLeft)
  5.     ;; 左对齐只更新 InsertionPoint
  6.     (vla-put-InsertionPoint obj (vlax-3d-point new-pt))
  7.     ;; 其他对齐方式同时更新两个属性
  8.     (progn
  9.       (vla-put-TextAlignmentPoint obj (vlax-3d-point new-pt))
  10.       (vla-put-InsertionPoint obj (vlax-3d-point new-pt))
  11.     )
  12.   )
  13. )
回复 支持 反对

使用道具 举报

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

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2025-11-28 10:18 , Processed in 0.155093 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表