几何尺寸与公差论坛------致力于产品几何量公差标准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, 02:21 PM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】sketch macro

sketch macro
hey guys,
i have a need to modify a sketch's sharp corners to something simlar to a fillet.
i recorded a macro which was less than helpful the issue i have is that when i record a macro it gives me the standard:
boolstatus = part.extension.selectbyid2("line1", "sketchsegment", -0.08898693897835, 0.01998979925235, 0, false, 0, nothing, 0)
where it is selecting a sketch seg already named "line1" or "line2" and working with it and for me that wont work.
the way i want mine set up is to find all outside sharp corners and treat them with a series of fillets. (see below)
basically i would need to edit up to 30 sketches and perform this macro. so the sketch segments named "line1" or whatever the name may be is irrelevant. however i do need to select the point of each sharp corner and then the lines that extend from that point to make sure i am drawing the fillets in the right direction.
i am not real familiar with drawings shapes within macros or editing existing sketches.
any resources or advice would be appreciated
thanks!
solidworks professional 2009 sp0
dual core amd opteron 2.21ghz cpu
4 gb ram
nvidia quadrofx 4500 w/ 512mb ram
jake,
this is a pretty complicated task. you can get all of the sketch segments in a sketch using the method "sketch.getsketchsegments". you can then loop through the segments and find out what type of sketch entity it is using method "sketchsegment.gettype". if the segment is a sketchline, get it's start and end points. you would then have to find the lines that share start/end point to get the corners and what lines are connected there. you would then need to determine if this corner is inside or outside. i think you could do this by having the user screen select a location inside the 2d sketch profile. you could then check this point location with respect to the two lines. if it is an inside corner the create the arc and fillet between it and the two lines.
wayne matus
texas engineering systems
if you are only adding fillets to external perimeters and not complex hollowed profiles too (such as interior cuts) then the task becomes much simplier.
you can determine the outside perimeter fairly easily and have a collection of entities. from that you then do your loop and the tricky part is determining the inner/outer preference.
to determine the orientation you need to select a start line and class the outside as being to the left of the normal direction, as you follow the loop class the outside as the left of the normal to all of the first lines out of the 2 that make the point. this will place the fillets in the same direction for that loop (inside or outside). then you can just offer the user a "flip" option to change the direction to right. you can add an undo command at the start of your code to remove and changes and re-add the fillets.
creating the fillets is then childs play.
still quite a lot of work depending on your skill level though, and then you need to add the folder browsing/file selecting process and a loop to process all files but again that is relatively simple.
thanks guys, this is the direction i was aiming for. i have about half of this completed although it is getting trickier now. i'll keep you posted though!
as for my exp: i have been a software developer for about 10 yrs. all my work has been in c++/vb and vfp (any fox pro users out there? lol) it was all erp based development. lots of database interaction via code and whatnot
anyway i would like to think i am pretty versed in oop in multiple languages. my weakness is that i am pretty new to this particular api so my "toolbox" is empty so to speak.
i read through sketch object pretty extensively last night and that opened a bunch of doors. basically i am getting familiar with the object model as i am developing things! needless to say... my first few macros are probably a little messy / inefficient!
solidworks professional 2009 sp0
dual core amd opteron 2.21ghz cpu
4 gb ram
nvidia quadrofx 4500 w/ 512mb ram
edited: 10/23/2008 at 07:21 am by jake johnson
i have never had a chance to use macros to edit a sketch so this looks like a complicated task to me, adding the sketch fillets like are shown in your picture and then hopefully fully defining the sketch
have you given any thought to adding a new feature. find the corners of a face of the part then add a predefined sketch to the corners and extruding or base-flange/tab if it is sheet metal, this could even be a block inserted, or even create a design library feature part and add that to the corners
showing all the reasoning and logic behind this code would make a good swugn presentation
cswa, cswp, cswp-smtl, sw 2009 sp2.0
hp xw4600 xp32, x9650 4gb, quadro fx3500
that would be good for a particular cnc problem that comes up. i suggest making a block. define dimensions that are editable, and constrained, maybe add values that you can edit without having to open the perameters. since your are changing a 90degree angle it should be easy to define.
edited: 10/31/2008 at 02:41 am by nathaniel taylor
true 90's would be easy although in my case there could be all sorts of angles (inside and outside)
i was actually broken off of this project to work on another one but i did make some significant progress on it while i was working on it. i plan on getting back into the code later this month!
i'll post back here as i progress.
solidworks professional 2009 sp0
dual core amd opteron 2.21ghz cpu
4 gb ram
nvidia quadrofx 4500 w/ 512mb ram
quick
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
 


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

高级搜索
显示模式

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

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

相似的主题
主题 主题发起者 论坛 回复 最后发表
【转帖】execute a sw macro from a macro of another software, is it possible yang686526 SolidWorks二次开发 0 2009-04-13 10:46 AM
【转帖】custom property macro bugging ou yang686526 SolidWorks二次开发 0 2009-04-13 10:09 AM
【转帖】macro for inserting and mating a new part in an assembly yang686526 SolidWorks二次开发 0 2009-04-12 09:38 PM
【转帖】how do i slow a macro down yang686526 SolidWorks二次开发 0 2009-04-12 09:10 PM
【转帖】copy an existent sketch into a macro yang686526 SolidWorks二次开发 0 2009-04-12 08:31 PM


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


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