"Can I do this with a macro?" I don't know. I could do it with a macro. Whether or not you can is another question. What is your ability? What is your plan? What are your thoughts on ways that this might be done? Are you just looking for someone to do it for you?
I can tell you it's probably going to involve EditMate4. There's an example in the API help.
I am glad to hear you can do it - I guess I just have to figure out how I will do it. While the literal translation of my question does imply that I would need the knowledge to do it, I guess I am more or less questioning if this is a simple operation, or something way more involved.
I have very little programming experience, but I have developed a few marcos. I am entirely self taught so I guess my programming ability is relatively limited, but better than not knowing anything.
I don't have a plan other than to edit the number of instances and update this mate. In searching for an answer I did not find much on updating mate references so I thought I would ask the question here.
I don't have any thoughts on how I would do this. I have never come across this previously, also, why I thought I would ask the question here.
I am not looking for someone to do it for me. If someone could point me to a good resource I would be happy to try to figure it out on my own. After looking at the API Help and EditMate4 it looks like I will be able to do just that. Thank you!
That was kind of the point of my post... Not really intending to be a jerk. We don't have a way to know if we need to tell you "go to Tools->Macro->Edit" or just point you to one or two topics in the help to kick-start you in the right direction. If it's the former, then no, you can't. Too much to learn. If the latter, you probably can. There are plenty of people who post vague API questions that wouldn't know a macro from a Word document and hope someone writes the code for 'em.
Do you already know how to edit the pattern feature? Do you already know how to programmatically find and select the face of interest on your last component?
Yes, I can edit the instances of my pattern. I do not know how to find the face of interest on my last component, but I am sure I will learn. Thank you for the Help Josh.
OK, here's the path you're going to need to take...
Use MateEntity on the mate of interest to get the currently-mated entity. And, of course, the other mated entity for EditMate2.
Might have to use GetCorresponding to get the entity in the context of the component's ModelDoc2. Not sure.
Use GetFirstSubFeature and GetNextSubFeature on the pattern feature to access the pattern instances.
Use GetSpecificFeature on the Feature object corresponding to the last pattern instance to return a Component2 object.
Use GetCorrespondingEntity (or one of those similar ones, I forget which) to get a reference to the entity on that specific Component2 instance in the context of the assembly. I'm not sure if you can go straight from the MateEntity to the correct entity on the new Component2 or if you'll have to do that second step above.
Select the mate, the entity on the new component, and the entity that stays in the mate. Then EditMate2.
The other thing I would caution is more related to assembly practices. I try to be very careful when positioning assembly components with mates to patterned components. Patterns don't seem to always solve simultaneously with mates. I have seen several instances of assemblies being unstable as far as positioning goes due to hanging too many components off the end of a patterned component.
Thank you for the help. I'm sure I will be able to complete this task now.
I agree that from an assembly practice standpoint this is a relatively unstable structure. This is likely a limited use case for these parts so I shouldn't get to much grumbling from my colleagues.
You can read Josh's comment and ask yourself what he is trying to say. Or you can feel upset about the fact that he might have not offered the help you would have expected. I do think you can learn a lot from someone like Josh. I would encourage you to look into the brass tax of his point and you will indeed see the benefits. I can only say that Josh is one of the top skilled users of SolidWorks in particular when it comes to programming. So he is definitely capable and knowledgeable.
I think it should go without saying. There is not entitlement or birthright to help. You can ask for help but can't demand it. If you don't get the help you are looking for then look into other options. See what you can do differently to change the outcome.
Ask yourself if your questions describe what you want to accomplish in a way that someone other than yourself can understand.
That's in a nutshell what Josh has tried to point out. He could have responded differently. You could have put some more effort in your post. No one the wiser. One word of advise. Check your ego at door and life will be better in the long run. Whether your name is Josh, Aaron or Elmar or whoever
Thank you for your insight. Your correct, I probably could have put more effort into my post, and Josh certainly seems like one of the "top skilled users of SolidWorks". I appreciate the help Josh has provided, and I have learned quite a bit as a result.
I agree, it goes without saying, there is not entitlement or birthright to help. I hope no one reads my initial post is assumes otherwise.
You can edit mates with IAssembly::EditMate4
Select the following items in the following order before calling this method:
- Mate feature to edit.
- Two model items to mate (that is, two faces, edge and face, and so on). The two model items must be selected with a selection mark of 1. See ISelectData or IModelDocExtension::SelectByID2 for details on using selection marks.