|
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 |
|