马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
本帖最后由 newer 于 2016-8-1 18:27 编辑
问题:
我需要把UCS对齐于弧线实体,我试了用UCS命令跟着E选项,但是我不能控制X、Y的旋转角,我要如何做才能把UCS对齐于弧线呢?
I need to align the UCS with an arc entity in my drawing. I tried using UCS
command with the Entity (E)option, but I have no control over the rotation of
the X and Y axes. How can I set my UCS to correspond with the geometry of my
arc?
回答:
You can use ActiveX from within AutoLISP to create your own UCS based upon the
geometry of your arc entity. Using ActiveX, you can obtain the arc's normal and
create a vector between the center and the startpoint, then calculate the third
axis from the cross product of the two. Use the Add method of the AcadUCSs
object to create a custom UCS based on the origin of the arc and points along
the X and Y axes, then make the new custom UCS current. The result will change
the UCS to make the origin correspond with the Arc's center, the Y axis will
point to the Startpoint ,the Z Axis will correspond with the arc's normal and
the X Axis will be calculated to be orthogonal to both according to the
right-hand rule. The same solution can be used with circle entities as well with
only slight modifications.
The following example is written n in Visual LISP that performs the operation:
![](source/plugin/imc_colorcode/images/loading.gif) - (defun C:UcsArc ()
- (vl-load-com)
- (setq acadObject (vlax-get-acad-object))
- (setq acadDoc (vla-Get-ActiveDocument acadObject))
- (setq anEnt (entsel "Select an Arc: "))
- (if anEnt
- (progn
- (setq entLst (entget (car anEnt) '("*")))
- (if (equal (cdr (assoc '0 entLst)) "ARC")
- (progn
- (setq arcObj (vlax-ename->vla-object (car anEnt)))
- (setq strtPt (vla-Get-StartPoint arcObj))
- (setq strtPtLst (vlax-safearray->list (vlax-variant-value strtPt)))
- (setq ctrPt (vla-Get-Center arcObj))
- (setq ctrPtLst (vlax-safearray->list (vlax-variant-value ctrPt)))
- (setq Norm (vla-Get-Normal arcObj))
- (setq NormLst (vlax-safearray->list (vlax-variant-value Norm)))
- (setq startVector (doListMinus strtPtLst ctrPtLst))
- (setq r1Vector (doCrossProduct NormLst startVector))
- (setq XAxis (doListMinus ctrPtLst r1Vector))
- (setq UCScollection (vla-Get-UserCoordinateSystems acadDoc))
- (setq ucsOrigin (vlax-3d-Point ctrPtLst) XAxisPoint (vlax-3d-Point
- XAxis) YAxisPoint (vlax-3d-Point strtPtLst))
- (if (setq newUCS (vla-Add UCScollection ucsOrigin XAxisPoint
- YAxisPoint "ArcUcs"))
- (princ "Created UCS Definition: ArcUcs"))
- (vla-put-ActiveUCS acadDoc newUCS)
- (if(not(vlax-object-released-p arcObj))
- (vlax-release-object arcObj))
- (if(not(vlax-object-released-p UCScollection))
- (vlax-release-object UCScollection))
- )
- )
- )
- )
- (if(not(vlax-object-released-p acadObject))
- (vlax-release-object acadObject))
- (if(not(vlax-object-released-p acadDoc))
- (vlax-release-object acadDoc))
- (princ)
- )
- ; (setq FstLst strtPtLst S**Lst ctr)
- (defun doListMinus (FstLst S**Lst)
- (setq X (- (car FstLst) (car S**Lst)))
- (setq Y (- (cadr FstLst) (cadr S**Lst)))
- (setq Z (- (caddr FstLst) (caddr S**Lst)))
- (list X Y Z)
- )
求叉积的函数:
|