| 
我们知道,使用ACAD的传统方法旋转一个块,属性文字角度是随之改变的。下面代码证实
×
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册 
    
 
   
 
  (defun c:tt2 ()
  (if (and (setq curve (car (xdrx_entsel
                              "\n拾取个曲线<退出>:"
                              '((0 . "*LINE,ARC,ELLIPSE,CIRCLE"))
                            )
                       )
           )
           (setq e (car        (xdrx_entsel
                          "\n拾取属性图块<退出>:"
                          '((0 . "INSERT") (66 . 1))
                        )
                   )
           )
      )
    (progn (setq pts (xdrx_getsamplept curve 1.0))
           (xdrx_getpropertyvalue e "position")
           (setq atts (xdrx_getpropertyvalue e "attributeEntities"))
           (setq mat (xdrx_matrix_identity 3))
           (setq an 0.0)
           (setq lastpoint #position)
           (mapcar '(lambda (x)
                      (command ".move" e "" lastpoint x)
                      (xdrx_getpropertyvalue e "position")
                      (setq lastpoint #position)
                      (command "rotate" e "" #position 10.0)
                      (xdrx_sleep 80)
                      (princ)
                    )
                   pts
           )
    )
  )
  (princ)
)
 下面使用XDRX API,旋转图块,属性文字角度保持不变。
 
 
   
 其实很简单,xdrx_setpropertyvalue 函数修改属性块角度的时候,对文字自动保持原来的角度不变。不用额外的处理。
 
 
  (defun c:tt ()
  (if (and (setq curve (car (xdrx_entsel
                              "\n拾取个曲线<退出>:"
                              '((0 . "*LINE,ARC,ELLIPSE,CIRCLE"))
                            )
                       )
           )
           (setq e (car        (xdrx_entsel
                          "\n拾取属性图块<退出>:"
                          '((0 . "INSERT") (66 . 1))
                        )
                   )
           )
      )
    (progn (setq pts (xdrx_getsamplept curve 1.0))
           (xdrx_getpropertyvalue e "position")
           (setq atts (xdrx_getpropertyvalue e "attributeEntities"))
           (setq mat (xdrx_matrix_identity 3))
           (setq an 0.0)
           (mapcar '(lambda (x)
                      (xdrx_getpropertyvalue e "position")
                      (setq m
                             (xdrx_matrix_settranslation mat (mapcar '- x #position))
                      )
                      (xdrx_entity_transform e m)
                      (xdrx_setpropertyvalue
                        e
                        "rotation"
                        (setq an (+ an (/ pi 18)))
                      )
                      (xdrx_sleep 80)
                      (princ)
                    )
                   pts
           )
    )
  )
  (princ)
)
 |