Функция вытянуть по траектории

Автор Тема: Функция вытянуть по траектории  (Прочитано 4164 раз)

0 Пользователей и 1 Гость просматривают эту тему.

Оффлайн Алексей123456789Автор темы

  • ADN OPEN
  • Сообщений: 30
  • Карма: 0
Подскажите функцию, которая будет вытягивать эскиз по траектории, за вытягивание отвечает ExtrudeFeature, но как сама функция реализуется, покажите на примере, пожалуйста, если есть возможность.

Оффлайн mikazakov

  • ADN
  • *
  • Сообщений: 752
  • Карма: 195
  • Skype: mikazakov@mail.ru
Re: Функция вытянуть по траектории
« Ответ #1 : 01-04-2016, 14:04:34 »
В хелпе есть пример на эту тему:
Код - Visual Basic [Выбрать]
  1. Public Sub SweepFeature()
  2.     ' Set a reference to the currently active document.
  3.    ' This assumes that it is a part document.
  4.    Dim oPartDoc As PartDocument
  5.     Set oPartDoc = ThisApplication.ActiveDocument
  6.  
  7.     ' Set a reference to the component definition.
  8.    Dim oCompDef As PartComponentDefinition
  9.     Set oCompDef = oPartDoc.ComponentDefinition
  10.  
  11.     ' Set a reference to the transient geometry object.
  12.    Dim oTG As TransientGeometry
  13.     Set oTG = ThisApplication.TransientGeometry
  14.  
  15.     ' Create some workpoints that will be used for the 3D sketch.
  16.    Dim oWPs(1 To 5) As WorkPoint
  17.     Set oWPs(1) = oCompDef.WorkPoints.AddFixed(oTG.CreatePoint(0, 0, 0))
  18.     Set oWPs(2) = oCompDef.WorkPoints.AddFixed(oTG.CreatePoint(3, 0, 0))
  19.     Set oWPs(3) = oCompDef.WorkPoints.AddFixed(oTG.CreatePoint(3, 4, 0))
  20.     Set oWPs(4) = oCompDef.WorkPoints.AddFixed(oTG.CreatePoint(3, 4, 2))
  21.     Set oWPs(5) = oCompDef.WorkPoints.AddFixed(oTG.CreatePoint(6, 4, 2))
  22.  
  23.     ' Create a new 3D Sketch.
  24.    Dim oSketch3D As Sketch3D
  25.     Set oSketch3D = oPartDoc.ComponentDefinition.Sketches3D.Add
  26.  
  27.     ' Draw 3D lines. The first line is drawn between two of the work points.
  28.    Dim oLine As SketchLine3D
  29.     Set oLine = oSketch3D.SketchLines3D.AddByTwoPoints(oWPs(1), oWPs(2), True, 1)
  30.  
  31.     ' This second and subsequent lines are drawn between a 3D sketch point and a work point.
  32.    ' The work point is obtained from the previous line. Because the two lines will share
  33.    ' this 3D sketch point, Inventor will treat them as connected lines when creating any
  34.    ' paths.
  35.    Set oLine = oSketch3D.SketchLines3D.AddByTwoPoints(oLine.EndPoint, oWPs(3), True, 1)
  36.     Set oLine = oSketch3D.SketchLines3D.AddByTwoPoints(oLine.EndPoint, oWPs(4), True, 0.75)
  37.     Set oLine = oSketch3D.SketchLines3D.AddByTwoPoints(oLine.EndPoint, oWPs(5), True, 1)
  38.  
  39.     ' Create a 2D sketch.
  40.    Dim oSketch As PlanarSketch
  41.     Set oSketch = oCompDef.Sketches.Add(oCompDef.WorkPlanes.Item(2))
  42.  
  43.     ' Determine the model origin relative to the sketch space.
  44.    Dim oOrigin As Point2d
  45.     Set oOrigin = oSketch.ModelToSketchSpace(oTG.CreatePoint(0, 0, 0))
  46.  
  47.     ' Create two lines.
  48.    Dim oNewPoint As Point2d
  49.     Set oNewPoint = oTG.CreatePoint2d(oOrigin.X, oOrigin.Y - 4)
  50.     Dim oSketchLine1 As SketchLine
  51.     Set oSketchLine1 = oSketch.SketchLines.AddByTwoPoints(oOrigin, oNewPoint)
  52.     oNewPoint.X = oNewPoint.X + 3
  53.     Dim oSketchLine2 As SketchLine
  54.     Set oSketchLine2 = oSketch.SketchLines.AddByTwoPoints(oSketchLine1.EndSketchPoint, oNewPoint)
  55.  
  56.     ' Create a fillet between the two lines.
  57.    Call oSketch.SketchArcs.AddByFillet(oSketchLine1, oSketchLine2, 1, oSketchLine1.StartSketchPoint.Geometry, oSketchLine2.EndSketchPoint.Geometry)
  58.  
  59.     ' Get the end of the 2d sketch in model space.
  60.    Dim oModelPoint As Point
  61.     Set oModelPoint = oSketch.SketchToModelSpace(oSketchLine2.EndSketchPoint.Geometry)
  62.  
  63.     ' Create a work plane at the end of the 2D sketch.
  64.    Dim oWP As WorkPlane
  65.     Set oWP = oCompDef.WorkPlanes.AddByNormalToCurve(oSketchLine2, oSketchLine2.EndSketchPoint)
  66.  
  67.     ' Create a path. Because the 3D and 2D sketches physically connect the path will include
  68.    ' both of them.
  69.    Dim oPath As Path
  70.     Set oPath = oCompDef.Features.CreatePath(oSketchLine2)
  71.  
  72.     ' Create a sketch containing a circle.
  73.    Set oSketch = oCompDef.Sketches.Add(oWP)
  74.     Set oOrigin = oSketch.ModelToSketchSpace(oTG.CreatePoint(0, 0, 0))
  75.     Call oSketch.SketchCircles.AddByCenterRadius(oSketch.ModelToSketchSpace(oModelPoint), 0.375)
  76.  
  77.     ' Create a profile.
  78.    Dim oProfile As Profile
  79.     Set oProfile = oSketch.Profiles.AddForSolid
  80.  
  81.     ' Create the sweep feature.
  82.    Dim oSweep As SweepFeature
  83.     Set oSweep = oCompDef.Features.SweepFeatures.AddUsingPath(oProfile, oPath, kJoinOperation)
  84. End Sub
  85.