Private Sub Nesting(n As Integer)
Dim oSketch As PlanarSketch
Dim oSketch3D As Sketch3D
Dim oSketchEllipticalArc As SketchEllipticalArc
Dim oSketchLine As SketchLine
Dim Rd As Double
Dim oTransGeom As TransientGeometry
Dim oCircle1 As SketchCircle
Dim oPoint As Point
Dim oDiameterDimConstraint As DiameterDimConstraint
Dim oTwoLineAngleDimConstraint As TwoLineAngleDimConstraint
Dim oAddOffset As OffsetDimConstraint
Dim oExtrudeFeature As ExtrudeFeature
Dim oProfileOne As Profile
Dim oExtrudeDef As ExtrudeDefinition
Dim oExtrude As ExtrudeFeature
Dim obj As ObjectCollection
Dim Lh As Double
'Зачистка от предыдущего выбранного раскроя
On Error Resume Next
oCompDef.Sketches3D.Item("Projection of welds").Delete
If Err Then
'MsgBox "1"
On Error Resume Next
oCompDef.Sketches3D.Item("Projection of welds").ExitEdit
oCompDef.Sketches3D.Item("Projection of welds").Delete
If Err Then
'MsgBox "11"
End If
End If
On Error Resume Next
For Each oExtrude In oCompDef.Features.ExtrudeFeatures
If oExtrude.Name Like "ProjWelds *" Then
oExtrude.Delete
End If
Next
If Err Then
'MsgBox "2"
End If
On Error Resume Next
oCompDef.Sketches.Item("Nesting").ExitEdit
oCompDef.Sketches.Item("Nesting").Delete
If Err Then
'MsgBox "3"
End If
'oParameters.Item("Angel").Delete
Lh = 2 * ohotbortovki.Value + oHvn.Value
Set oSketch = oCompDef.Sketches.Item("SketchBottom")
Set oSketchEllipticalArc = oSketch.SketchEllipticalArcs.Item(2)
Set oSketchLine = oSketch.SketchLines.Item(2)
Rd = oSketchEllipticalArc.Length + oSketchLine.Length
Set oSketch = oCompDef.Sketches.Add(oCompDef.WorkPlanes(3))
oSketch.Name = "Nesting"
Set oTransGeom = ThisApplication.TransientGeometry
Set oCircle1 = oSketch.SketchCircles.AddByCenterRadius(oTransGeom.CreatePoint2d(0, 0), Rd)
Call oSketch.GeometricConstraints.AddGround(oCircle1.CenterSketchPoint)
Set oDiameterDimConstraint = oSketch.DimensionConstraints.AddDiameter(oCircle1, oTransGeom.CreatePoint2d(0, 0))
oDiameterDimConstraint.Parameter.Name = "DimSweep"
oDiameterDimConstraint.Parameter.Comment = "Теоретический диаметр заготовки"
Set oSketchLine = oSketch.SketchLines.AddByTwoPoints(oTransGeom.CreatePoint2d(0, 0), oTransGeom.CreatePoint2d(0, Rd))
Call oSketch.GeometricConstraints.AddCoincident(oSketchLine.StartSketchPoint, oCircle1.CenterSketchPoint)
Call oSketch.GeometricConstraints.AddCoincident(oSketchLine.EndSketchPoint, oCircle1)
Call oSketch.GeometricConstraints.AddVertical(oSketchLine)
oSketchLine.Construction = True
Select Case n
'....
'....
'Построение эскиза раскроя и проецирование линий сварных швов на поверхность днища
Case 12
Set oCircle1 = oSketch.SketchCircles.AddByCenterRadius(oSketch.SketchCircles.Item(1).CenterSketchPoint, oDvn.Value / 3)
Call oSketch.GeometricConstraints.AddGround(oCircle1.CenterSketchPoint)
Set oDiameterDimConstraint = oSketch.DimensionConstraints.AddDiameter(oCircle1, oTransGeom.CreatePoint2d(0, 0))
oDiameterDimConstraint.Parameter.Name = "DimCentralSegment"
Set oProfileOne = oSketch.Profiles.AddForSurface(oCircle1)
Set oExtrudeDef = oCompDef.Features.ExtrudeFeatures.CreateExtrudeDefinition(oProfileOne, kSurfaceOperation)
Call oExtrudeDef.SetDistanceExtent(Lh, kPositiveExtentDirection)
Set oExtrude = oCompDef.Features.ExtrudeFeatures.Add(oExtrudeDef)
oExtrude.Name = "ProjWelds 1"
Set oSketchLine = oSketch.SketchLines.AddByTwoPoints(oTransGeom.CreatePoint2d(0, oDvn.Value / 3), oTransGeom.CreatePoint2d(0, Rd))
Call oSketch.GeometricConstraints.AddCoincident(oSketchLine.StartSketchPoint, oCircle1)
Call oSketch.GeometricConstraints.AddCoincident(oSketchLine.EndSketchPoint, oSketch.SketchCircles.Item(1))
Call oSketch.GeometricConstraints.AddCoincident(oSketchLine, oSketch.SketchCircles.Item(1).CenterSketchPoint)
Set oTwoLineAngleDimConstraint = oSketch.DimensionConstraints.AddTwoLineAngle(oSketch.SketchLines.Item(1), oSketch.SketchLines.Item(2), oTransGeom.CreatePoint2d(0, Rd / 2))
oTwoLineAngleDimConstraint.Parameter.Name = "Angel"
Set oProfileOne = oSketch.Profiles.AddForSurface(oSketchLine)
Set oExtrudeDef = oCompDef.Features.ExtrudeFeatures.CreateExtrudeDefinition(oProfileOne, kSurfaceOperation)
Call oExtrudeDef.SetDistanceExtent(Lh, kPositiveExtentDirection)
Set oExtrude = oCompDef.Features.ExtrudeFeatures.Add(oExtrudeDef)
oExtrude.Name = "ProjWelds 2"
Dim k As Integer
Dim k1 As Double
k = 3
k1 = 2 * pi / (k + 1)
For i = 1 To k
Set oSketchLine = oSketch.SketchLines.AddByTwoPoints(oTransGeom.CreatePoint2d(0, oDvn.Value / 3), oTransGeom.CreatePoint2d(0, Rd))
Set obj = ThisApplication.TransientObjects.CreateObjectCollection
Call obj.Add(oSketchLine)
Call oSketch.GeometricConstraints.AddCoincident(oSketchLine.StartSketchPoint, oCircle1)
Call oSketch.GeometricConstraints.AddCoincident(oSketchLine.EndSketchPoint, oSketch.SketchCircles.Item(1))
Call oSketch.GeometricConstraints.AddCoincident(oSketchLine, oSketch.SketchCircles.Item(1).CenterSketchPoint)
Call oSketch.RotateSketchObjects(obj, oTransGeom.CreatePoint2d(0, 0), i * 2 * pi / (k + 1), False, False)
Set oTwoLineAngleDimConstraint = oSketch.DimensionConstraints.AddTwoLineAngle(oSketch.SketchLines.Item(2), oSketch.SketchLines.Item(i + 2), oTransGeom.CreatePoint2d(0, Rd / 2))
Set oProfileOne = oSketch.Profiles.AddForSurface(oSketchLine)
Set oExtrudeDef = oCompDef.Features.ExtrudeFeatures.CreateExtrudeDefinition(oProfileOne, kSurfaceOperation)
Call oExtrudeDef.SetDistanceExtent(Lh, kPositiveExtentDirection)
Set oExtrude = oCompDef.Features.ExtrudeFeatures.Add(oExtrudeDef)
oExtrude.Name = "ProjWelds " & i + 2
Next i
Set oSketch3D = oCompDef.Sketches3D.Add
oSketch3D.Name = "Projection of welds"
For i = 1 To k + 2
Set oExtrude = oCompDef.Features.ExtrudeFeatures.Item("ProjWelds " & i)
Call oSketch3D.IntersectionCurves.Add(oCompDef.SurfaceBodies.Item(1), oExtrude.SurfaceBodies.Item(1))
oExtrude.Faces.Item(1).SurfaceBody.Visible = False
Next i
oSketch.Visible = True
'....
'....
End Select
oPart.Update
End Sub