You need to specify the full path of that file with extension and in quotes. For e.g.
Set Part2 = "C:\Program Files\SolidWorks Corp\SolidWorks\samples\tutorial\swutilities\bracket_a.sldprt"
Part.Extension.SelectByID2 "File Name @ Assembly Name", "COMPONENT", 0, 0, 0, False, 0, Nothing, 0)
Set swComponent = Part.SelectionManager.GetSelectedObject6(1, -1)
Set Part2 = swComponent.GetModelDoc
Thank you for the help! I've almost got it. I'm using the second option of your answer as the file locations might differentiate from system to system here. I am also not understanding the last two lines of that code though and what they do. The reason being the error I am currently getting.
I got the macro to work! The initial code I used for reference had this command line in it:
swWzdHole.InitializeHole swWzdCounterBore, swStandardISO, swStandardISOHexBolt, "M48", swEndCondBlind
This is not the correct hole that I will need. I modified the code to reflect a 10-32 tapped hole. Below is the modified code.
swWzdHole.InitializeHole swWzdTap, swStandardPCS, swStandardPCSTappedHole, "#10-32", swEndThreadTypeBLIND
This code crashes SolidWorks. Is there anything you see here that is causing this issue?
Works fine for me. Could you try using HoleWizard5 instead?
I got it to work with a little help! A few last things. How do I show the cosmetic thread instead of it being an actual cut? And lastly when selecting another instance of the same part how do I control the orientation of the hole.
- The hole on the left is a hole wizard feature that has a cosmetic thread on it. The hole on the left is the same hole as the picture above it, but the threading is not cosmetic.
-Orientation of macro created holes are not correct.
Thank you! You have helped me a lot!