查看单个帖子
旧 2009-04-20, 11:45 AM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 objectarx 座标转换

objectarx 座标转换
www.dimcax.com
objectarx 座标转换
网上看到很多人在找关于objectarx 座标转换问题的解决方法,可以先将点转换,也可将实体转换,以下代码是在屏幕上获取一个点,并转换到wcs。
<commandmethod("uptwp")> public function ucspointtowcspoint() as point3d
dim ed as editor = application.documentmanager.mdiactivedocument.editor
dim ptopts as new promptpointoptions("enter start point")
dim mt as matrix3d = ed.currentusercoordinatesystem
dim ptres as promptpointresult = ed.getpoint(ptopts)
dim ucspoint3d as point3d = ptres.value
dim wcspoint3d as point3d = ucspoint3d.transformby(mt)
return wcspoint3d
end function
复制代码
[
''' <summary>从ucs转换到wcs。</summary>
''' <param name="t">要转换的点.</param>
public shared function ucstowcs(byval pt as point3d) as point3d
dim ed as editor = application.documentmanager.mdiactivedocument.editor
dim mt as matrix3d = ed.currentusercoordinatesystem
dim newpoint as point3d = pt.transformby(mt)
return newpoint
end function
''' <summary>从wcs转换到ucs。</summary>
''' <param name="t">要转换的点.</param>
public shared function wcstoucs(byval pt as point3d) as point3d
dim db as database = application.documentmanager.mdiactivedocument.database
dim vect as vector3d = db.ucsorg.getvectorto(new point3d(0, 0, 0))
dim mt as matrix3d = matrix3d.displacement(vect)
dim newpoint as point3d = pt.transformby(mt)
return newpoint
end function
复制代码
[
good take!
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)