几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量  


返回   几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 » 仿射空间:CAX软件开发(三)二次开发与程序设计 » CAD二次开发 » SolidWorks二次开发
用户名
密码
注册 帮助 会员 日历 银行 搜索 今日新帖 标记论坛为已读


回复
 
主题工具 搜索本主题 显示模式
旧 2009-04-13, 10:19 AM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】determine whether sketch is facing towardaway from origin,

determine whether sketch is facing toward/away from origin,
i am working i a macro and need to be able to determine within the macro whether or not a sketch is facing toward or away from the origin. i would then use this information in an if statement later.
in my macro a sketch is created (gear tooth profile) and then within the same macro another sketch is created to define the path of a swept cut. the path would change depending on whether the first sketch was facing toward the origin or away.
can anyone help me out?

check out our whitepaper library.
i'm not sure myself, but could you create points and have it determine the coordinates of the points for the path?
a guess...
chris
solidworks/pdmworks 08 3.1
autocad 08
what do you mean by "facing the origin"? do you mean that the sketch is on some plane that does not pass through the origin, and you need to determine whether the sketch's normal vector points toward or away from the origin?
-handleman, cswp (the new, easy test)
correct, the sketch is on some plane that does not pass through the origin, and i need to determine whether the sketch's normal vector points toward or away from the origin.
really, when i create my swept cut path i just want to ensure that it is going through the part.
referencing the attached screen shot, if i started my gear tooth sketch on the opposite of the part, my swept path would have still gone to the left rather than intersecting the part.
the only way i can think of to do this is fairly complicated. the basic idea is to get the normal vector for the plane or face on which the sketch resides and compare it to the closest distance between the plane/face and the origin.
to get the plane or face on which the sketch resides, use sketch::getreferenceentity. this will be either a plane or a planar face. the method for dealing with each is slightly different. do you have any experience with vector algebra and transformation matrices? i sure hope so...
if the sketch resides on a plane, you will need to use refplane::transform to get the mathtransform object for the plane. this mathtransform is a 3d transformation matrix that basically gives the data for the plane. from this you can create the normal vector mathvector object).
if the sketch resides on a planar face, then the normal vector (mathvector) can be had directly from face2::normal.
now that you have a normal vector to the face or plane (vector length is unimportant) you need to get a vector from your plane/face to the origin. this can be created from the point data gotten from modeldoc2::closestdistance. if you have a plane, the vector gotten through closestdistance will be either pointing in exactly the same direction as the normal vector or in exactly the opposite. if you have a planar face, the vector may or may not be directly normal to the face, because the origin may be outside the boundary of the normal projection of the planar face. however, this doesn't matter. all you care about is the angle between the two vectors. if the angle is greater than 90 degrees, your plane normal points away from the origin. if it's less than 90 degrees, the normal points toward the origin. take the dot product of the two vectors using mathvector::dot. if the dot product is a negative number then the angle is greater than 90 degrees and the sketch normal points away from the origin. if the dot product is positive then the angle is less than 90 degrees and the normal points toward the origin.
-handleman, cswp (the new, easy test)
if possible and not too much trouble, could you provide sample code that one may use to do something like this? i am not as familiar with solidworks macros as i would like to be.
regardless, thanks for your assist. you've been a great resource.
unfortunately, i don't have anything. i'm also pretty short on time as i'm trying to get ready to be out on vacation. the distance mate macro found at
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
回复


主题工具 搜索本主题
搜索本主题:

高级搜索
显示模式

发帖规则
不可以发表新主题
不可以回复主题
不可以上传附件
不可以编辑您的帖子

vB 代码开启
[IMG]代码开启
HTML代码关闭

相似的主题
主题 主题发起者 论坛 回复 最后发表
【转帖】origin of drawing view related to origin of model in the veiw yang686526 SolidWorks二次开发 0 2009-04-12 09:58 PM
【转帖】linked sketch text now possible1 9sort of0 yang686526 SolidWorks二次开发 0 2009-04-12 09:34 PM
【转帖】copy an existent sketch into a macro yang686526 SolidWorks二次开发 0 2009-04-12 08:31 PM
Draft International Standard Iso/dis 10303-108 huangyhg ISO standards 2 2007-01-02 12:55 PM


所有的时间均为北京时间。 现在的时间是 10:04 AM.


于2004年创办,几何尺寸与公差论坛"致力于产品几何量公差标准GD&T | GPS研究/CAD设计/CAM加工/CMM测量"。免责声明:论坛严禁发布色情反动言论及有关违反国家法律法规内容!情节严重者提供其IP,并配合相关部门进行严厉查处,若內容有涉及侵权,请立即联系我们QQ:44671734。注:此论坛须管理员验证方可发帖。
沪ICP备06057009号-2
更多