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

how can i rename a previously made mate?
okay, this routine is turning out great, thanks for everyone's help and input!
so far, my routine allows you to browse for an assembly, then it pops up a form asking for various dimensions, then it creates distance and angle mates based on those dimensions, then moves the assembly into a new folder with a specified name.
what about renaming the mates so they're easy to track down the road? how can i rename a mate i just made using.....
'add right plane to axis distance mate
boolstatus = assy.extension.selectbyid2("right plane@" & swcomp.name2 & "@" & swrootcomp.name2, "plane", 0, 0, 0, false, 0, nothing, 0)
boolstatus = assy.extension.selectbyid2("axis1", "axis", 0, 0, 0, true, 0, nothing, 0)
assy.addmate3 swmatedistance, 2, 0, mycl, mycl, mycl, 0, 0, 0, 0, 0, false, longerror
i recorded myself renaming the mate, and this is what i got.... but what if i don't know the name? is there any way to select the last created entity? here is the basic, "select the mate by name and rename it" macro... but what if i don't know the name of the last created mate.
boolstatus = part.extension.selectbyid2("distance35", "mate", 0, 0, 0, false, 0, nothing, 0)
boolstatus = part.extension.selectbyid2("distance35", "mate", 0, 0, 0, false, 0, nothing, 0)
boolstatus = part.selectedfeatureproperties(0, 0, 0, 0, 0, 0, 0, 1, 0, "distance36")
is there a "select previous" command in api?
-wes
wes mosier
cswp in '03 & '08
.forefrontstudios.com
2009 premium x64 bit
dim mymate as feature
set mymate = assy.addmate3(0, 0, false, 0, 0, 0, 0.001, 0.001, 0.001, 0, 0, false, longstatus)
mymate.name = "new mate"
there is also a getlastfeatureadded command, but ivana's way is best and easiest in this case. some feature creation functions don't return the new feature, so getlastfeatureadded works for those.
i'll get you eh steve, if it's the last thing i dooooo!
okay, i get it, if i define the variable "mymate" to be a feature (a mate), then tell solidworks to make mymate = the mate itself, i can simply rename the mate feature with the ".name" definition. very cool!
the vb editor won't let me do it though....
'add right plane to axis distance mate
boolstatus = assy.extension.selectbyid2("right plane@" & swcomp.name2 & "@" & swrootcomp.name2, "plane", 0, 0, 0, false, 0, nothing, 0)
boolstatus = assy.extension.selectbyid2("axis1", "axis", 0, 0, 0, true, 0, nothing, 0)
dim mymate as feature
set mymate = assy.addmate3 swmatedistance, 2, 0, mycl, mycl, mycl, 0, 0, 0, 0, 0, false, longerror
mymate.name = "noz - " & mynoz & "mate c"
the highlighted line above turns red, the swmatedistance highlights blue, and the editor tells me...
compile error: expected end of statement
did i do something wrong?
wes mosier
cswp in '03 & '08
.forefrontstudios.com
2009 premium x64 bit
answer set mymate = assy.addmate3( swmatedistance, 2, 0, mycl, mycl, mycl, 0, 0, 0, 0, 0, false, longerror )
okay, so in other words...
it worked before, because the assy.addmate3 was the only function that i was using on that line.
when i added the set mymate = assy.ddmate3, the (swmate distance....etc..) became a sort of (sub-command to be run prior to setting the mymate value)
makes sense.
thanks everyone for all your patience with me! my var isn't scheduled to have a class on api for a while, so you've been a great help! special thanks to you ivana!
-wes mosier
lortz manufacturing
bakersfield, ca
wes mosier
cswp in '03 & '08
.forefrontstudios.com
2009 premium x64 bit
it is default behavior of vb. if you use "=" (or call statement) when calling a procedure then argumentlist must be enclosed in parentheses.
i'd like to expand the question a bit.
what would be the best way to traverse all mates in an assembly?
matt lorono
solidworks 2007 sp3.1
cad engineer/ecn analyst
i'd probably traverse features and check each one to see if it's a mate.
i'll get you eh steve, if it's the last thing i dooooo!
there is an example in api help
get mates and mate entities example (vb)
this example shows how to traverse a featuremanager design tree and get all of the assemblies mates and mate entities.
quick
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
 


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

高级搜索
显示模式

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

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



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


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