Split macro
-
- Posts: 6
- Joined: Mon Apr 15, 2024 2:03 am
- x 4
- x 2
Split macro
Hi all.
I've been struggling with a library feature for some time now that can split 80mm, 120mm, 160mm, 200mm etc shapes in to 40mm thick bodies we feed to a router. They need to be precisely 40mm for the nesting program to work. While library features works like a charm for cutting and numbering our router parts, it's just impossible to work with for this splitting purpose, due to the features working on other bodies than intended and only "non boolean features" allowed. Does anyone have any experience with using macros for splitting? I can only see examples of splitting and saving to new parts but I need the bodies to stay in the document. Is macro the way to go you think?
I've been struggling with a library feature for some time now that can split 80mm, 120mm, 160mm, 200mm etc shapes in to 40mm thick bodies we feed to a router. They need to be precisely 40mm for the nesting program to work. While library features works like a charm for cutting and numbering our router parts, it's just impossible to work with for this splitting purpose, due to the features working on other bodies than intended and only "non boolean features" allowed. Does anyone have any experience with using macros for splitting? I can only see examples of splitting and saving to new parts but I need the bodies to stay in the document. Is macro the way to go you think?
The reverse direction button was put in because there are scenarios where it tries to start splitting things in the wrong direction. I didn't make it smart enough to determine the direction itself but it's possible to do that.
To set a default value, you can modify the form in the VBA editor to set the text box value and radio button selections so that they start at the ones you want.
To cut the current body and not make a new body, you can change the following line in the BuildMacroFeature function
Remove this
Replace with this
I've added the default values and made it modify the current body. Macro is attached.
Go to full postTo set a default value, you can modify the form in the VBA editor to set the text box value and radio button selections so that they start at the ones you want.
To cut the current body and not make a new body, you can change the following line in the BuildMacroFeature function
Remove this
Code: Select all
Set swCopyBody = swBody.Copy2(False)
Code: Select all
Set swCopyBody = swBody
Re: Split macro
Maybe you could do this with an "Intersect" feature. To do that, you'd make a stack of blocks for every other layer then run Intersect. One does have to select which bodies to delete manually.
It would be nice if using the Combine feature with the "common" operation type had the option of not merging bodies. That could be closer to what you want.
It would also be nice if every cut operation had the option to retain all the bodies.
The Split feature always did seem to me to be a bad implementation. Why complicate it with part export? I don't understand what the check boxes mean; I just check them all and it seems to work.
Dwight
It would be nice if using the Combine feature with the "common" operation type had the option of not merging bodies. That could be closer to what you want.
It would also be nice if every cut operation had the option to retain all the bodies.
The Split feature always did seem to me to be a bad implementation. Why complicate it with part export? I don't understand what the check boxes mean; I just check them all and it seems to work.
Dwight
Re: Split macro
I could see this working as a macro feature, but that is probably one of the more complex things to develop with the API.
My thought is that you could take the the starting face and the thickness as an input and it could copy/cut the body to create the desired features. This is certainly an interesting proposal.
My thought is that you could take the the starting face and the thickness as an input and it could copy/cut the body to create the desired features. This is certainly an interesting proposal.
Re: Split macro
What about using an Extrude Cut, Thin Feature? I don't use library features, so I'm not sure if this is feasible or not.
-
I may not have gone where I intended to go, but I think I have ended up where I needed to be. -Douglas Adams
I may not have gone where I intended to go, but I think I have ended up where I needed to be. -Douglas Adams
-
- Posts: 9
- Joined: Wed Feb 01, 2023 5:10 pm
- x 1
Re: Split macro
In SW2025 this will be much easier because you can then pattern reference geometry. Attached is a library feature to help automate this a bit in the meantime.
Drag the feature into your part, select the top plane or face of the part, then the bottom plane or face, then any plane that runs through the entirety of the part you are trying to split. Usually one of the three primary planes will be fine. Run the split command and control select all planes, done.
Drag the feature into your part, select the top plane or face of the part, then the bottom plane or face, then any plane that runs through the entirety of the part you are trying to split. Usually one of the three primary planes will be fine. Run the split command and control select all planes, done.
- Attachments
-
- split planes.SLDLFP
- (154.39 KiB) Downloaded 46 times
-
- JUNK.SLDPRT
- (147.27 KiB) Downloaded 45 times
Re: Split macro
I put something together as a proof of concept. It's still buggy and needs work but it shows about how this can function. I'm not going to have time to work on it for some time so it's here for anyone else that wants to tinker.
There isn't currently an edit for the control, you'd have to delete and re-add the feature to change the settings and face selection.
The feature copies the body that the selected face belongs to and slices it in the normal direction of that face using the thickness setting to determine how many bodies to make. The original body isn't modified, but the new sliced bodies are created in place along with it.
Disclaimer: It's not clean code, I got it to the point where it functions.
There isn't currently an edit for the control, you'd have to delete and re-add the feature to change the settings and face selection.
The feature copies the body that the selected face belongs to and slices it in the normal direction of that face using the thickness setting to determine how many bodies to make. The original body isn't modified, but the new sliced bodies are created in place along with it.
Disclaimer: It's not clean code, I got it to the point where it functions.
- Attachments
-
- SliceMacroFeature.swp
- (157 KiB) Downloaded 46 times
-
- Posts: 6
- Joined: Mon Apr 15, 2024 2:03 am
- x 4
- x 2
Re: Split macro
Thanks everybody for taking an interest to my niche problem.
And thank you AlexB. You hit the nail on the head with this one! SliceMacroFeature does exactly what I'm after. Though there is no edit it seems to function really well with construction history, so it's not really needed, I guess. Also It only slices the selected body so no need for isolating anything.
This could be a real time saver in my company. I'd be really happy to modify it slightly, if there is another kind soul out there with a better understanding of programming language than me:
Get rid of the dialog box and the reverse direction option, set it to 40mm by default and delete the original body.
That would be AWESOME!
Thanks again Alex
And thank you AlexB. You hit the nail on the head with this one! SliceMacroFeature does exactly what I'm after. Though there is no edit it seems to function really well with construction history, so it's not really needed, I guess. Also It only slices the selected body so no need for isolating anything.
This could be a real time saver in my company. I'd be really happy to modify it slightly, if there is another kind soul out there with a better understanding of programming language than me:
Get rid of the dialog box and the reverse direction option, set it to 40mm by default and delete the original body.
That would be AWESOME!
Thanks again Alex
Re: Split macro
The reverse direction button was put in because there are scenarios where it tries to start splitting things in the wrong direction. I didn't make it smart enough to determine the direction itself but it's possible to do that.
To set a default value, you can modify the form in the VBA editor to set the text box value and radio button selections so that they start at the ones you want.
To cut the current body and not make a new body, you can change the following line in the BuildMacroFeature function
Remove this
Replace with this
I've added the default values and made it modify the current body. Macro is attached.
To set a default value, you can modify the form in the VBA editor to set the text box value and radio button selections so that they start at the ones you want.
To cut the current body and not make a new body, you can change the following line in the BuildMacroFeature function
Remove this
Code: Select all
Set swCopyBody = swBody.Copy2(False)
Code: Select all
Set swCopyBody = swBody
- Attachments
-
- SliceMacroFeature.swp
- (122 KiB) Downloaded 17 times
-
- Posts: 6
- Joined: Mon Apr 15, 2024 2:03 am
- x 4
- x 2
Re: Split macro
Thanks again. Absolutely brilliant!