Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Distance Mate Macro (re-visited)

Status
Not open for further replies.

brengine

Mechanical
Apr 19, 2001
616
Continuation of thread559-202450...

Handleman,

I finally had a (for lack of a better word) opportunity to delve into the InsertDistanceMate macro you wrote. One thing I've come across is that with AddMate3...even tho you specify AlignmentCLOSEST, the command does not obey that. I saw all of the additional code you used to try and get the part back to it's original position, but it still didn't prove to be 100% bulletproof for me (in predicting the initial position, everything else worked great). The Alignment and Flip seem to have a mind of their own, and it was very difficult to predict what they would do when creating test mates over-and-over and watching the behavior.

So I was tinkering with the code, and discovered this:
[ul]
[li]AddMate2 is just as unreliable/unpredictable (requiring the major trial and error, as you had went thru)[/li]

[li]AddMate on the other hand does not move the part around at all. It actually does apply the Aligned/Anti-Aligned that is the CLOSEST. And you already had the legwork done to find the inital distance and Flip orientation, so using this code rather than AddMate3 has so far been working really well for me.
[/li]
[/ul]
Code:
swAssy.AddMate swMateDISTANCE, swMateAlignCLOSEST, False, CurDist, 0
Obviously, the major drawback with this command is that it is obsolete. But for now it still seems to work well. Below is the topic from the API Help.

Enjoy,
Ken

 
Replies continue below

Recommended for you

Thanks, Ken! I have noticed that the Flip is a bit unreliable in cases where the mate that is added overdefines the assembly, but I hadn't noticed a problem with the alignment. However, it's quite possible that I haven't been paying that close of attention either. :) I'll make a point to be more observant and see if it's happening on my end too.

While we're on the subject of mating macros, one tweak I've added (and it only takes a single line of code!) to the ones I'm using is that at the very end of the macro it re-selects the first of the two selections that the user selected for mating. That makes it easy to ctrl-select another entity in the times when you want to mate a bunch of things to a single entity.

-handleman, CSWP (The new, easy test)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor