How to achieve the alignment of the insertion holes in the assembly coordinate system?

Programming and macros
POL
Posts: 1
Joined: Fri Oct 22, 2021 3:26 am
Answers: 0

How to achieve the alignment of the insertion holes in the assembly coordinate system?

Unread post by POL »

When you insert holes into different parts in the assembly coordinate system, the holes are inserted offset, although the coordinates are the same for both parts. Please tell me how to get rid of this.
A snippet of code is shown below.

Insert holes in the first part

Dim swHoleFeature As SldWorks.Feature
Dim swFeat As SldWorks.Feature
Dim swErrors As Long
Dim swWarnings As Long
ReDim KoardOtvKonf(2, line_) As Double
For i = 0 To KolKonf
boolstatus = swPartDocExt.SelectByID2("", "FACE", KoardOtvKonf(0, i), KoardOtvKonf(1, i), KoardOtvKonf(2, i), False, 0, Nothing, 0)
swModel.EditPart
boolstatus = swPartDocExt.SelectByID2("", "FACE", KoardOtvKonf(0, i), KoardOtvKonf(1, i), KoardOtvKonf(2, i), False, 0, Nothing, 0)
Set swFeat = swFeatMgr.HoleWizard5(swWzdHole, swStandardISO, swStandardISODrillSizes, ChrW(216) + "4.5", swEndCondBlind, 0.0045, 0.034, -1, 0, 2.05948851735331, 0, 0, 0, 0, 0, -1, -1, -1, -1, -1, "", False, True, True, True, True, False)
Next
swModel.AssemblyPartToggle
swModel.EditAssembly
boolstatus = swModel.Save3(1, swErrors, swWarnings)

Insert holes in a second part

For i = 0 To KolKonf
boolstatus = swPartDocExt.SelectByID2("", "FACE", KoardOtvKonf(0, i), KoardOtvKonf(1, i), KoardOtvKonf(2, i), False, 0, Nothing, 0)
swModel.EditPart
boolstatus = swPartDocExt.SelectByID2("", "FACE", KoardOtvKonf(0, i), KoardOtvKonf(1, i), KoardOtvKonf(2, i), False, 0, Nothing, 0)
Set swFeat = swFeatMgr.HoleWizard5(swWzdHole, swStandardISO, swStandardISODrillSizes, ChrW(216) + "7", swEndCondBlind, 0.0045, 0.025, -1, 0, 2.05948851735331, 0, 0, 0, 0, 0, -1, -1, -1, -1, -1, "", False, True, True, True, True, False)
Next
swModel.AssemblyPartToggle
swModel.EditAssembly
boolstatus = swModel.Save3(1, swErrors, swWarnings)

Hole insertion result
image.png
image.png
Insertion coordinates in a macro
X = 0.25; Y = -0.009; Z = 0.126

Insertion coordinates in the model
image.png
​​​​​​​A question of the accuracy of the coordinates?
Post Reply