-
Re: Creating holes automatically
John Stoltzfus Jul 14, 2017 2:17 PM (in response to Swaminathan Angannan) -
Re: Creating holes automatically
Peter Brinkhuis Jul 18, 2017 1:51 PM (in response to Swaminathan Angannan)Once you have solved your point issue you're going to run into the Hole Wizard API. My advice is to not even try. I'd love to hear it if you get it to work though
-
Re: Creating holes automatically
John Alexander Jul 18, 2017 2:27 PM (in response to Swaminathan Angannan)It looks like you are using the same values from component1 when creating the sketch points in component 2.
Each sketch has a coordinate system and each each component in an assembly has a coordinate system. If you measure the position of a point in your hole feature from holeWizardSketch@component1, you need to apply a transform to those coordinates before using them in holeWizardSketch@component2.
If you want to go from sketch1@componentA to sketch2@componentB, it would look like this:
Dim swComponentA As SldWorks.Component2
Dim swComponentB As SldWorks.Component2
Dim swSketch2 As SldWorks.Sketch
Dim swSketch2 As SldWorks.Sketch
Dim swSk1ToSk2Transform As SldWorks.MathTransform
Dim swCompATransform As SldWorks.MathTransform
Dim swCompBTransform As SldWorks.MathTransform
Dim swSk1toModelTransform As SldWorks.MathTransform
Dim swSk2toModelTransform As SldWorks.MathTransform
Set swComp1Transform = swComponentA.Transform2 'storing these in variables isn't necessary, they are included for readability
Set swComp2Transform = swComponentA.Transform2
Set swSk1toModel1Transform = swSketch1.ModelToSketchTransform
Set swSk2toModel2Transform = swSketch2.ModelToSketchTransform
Set swSk1ToSk2Transform = swSk1toModel1Transform.MultiplyTransform(swComp1Transform).MultiplyTransform(swComp2Transform.Inverse).MultiplyTransform(swSk2toModel2Transform.Inverse)
2012 SOLIDWORKS API Help - ModelToSketchTransform Property (ISketch)
2012 SOLIDWORKS API Help - Transform2 Property (IComponent2)