свойства объекта Face C#

Автор Тема: свойства объекта Face C#  (Прочитано 1626 раз)

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

Оффлайн glebShevАвтор темы

  • ADN OPEN
  • Сообщений: 17
  • Карма: 0
свойства объекта Face C#
« : 31-05-2021, 21:20:26 »
Здравствуйте. Я получаю объект Face кликом. Как можно проверить является ли грань цилиндрической и если является определить ее диаметр?

Оффлайн Александр Ривилис

  • Administrator
  • *****
  • Сообщений: 13829
  • Карма: 1784
  • Рыцарь ObjectARX
  • Skype: rivilis
Re: свойства объекта Face C#
« Ответ #1 : 31-05-2021, 21:34:38 »
Здравствуйте. Я получаю объект Face кликом. Как можно проверить является ли грань цилиндрической и если является определить ее диаметр?
А ведь всё это есть в документации:

Код - Visual Basic [Выбрать]
  1. Public Sub IsCylindricalFaceInterior()
  2.     Dim oDoc As Document
  3.     Set oDoc = ThisApplication.ActiveDocument
  4.    
  5.     If Not Typeof oDoc.SelectSet(1) Is Face Then
  6.         MsgBox "A face must be selected."
  7.         Exit Sub
  8.     End If
  9.    
  10.     Dim oFace As Face
  11.     Set oFace = oDoc.SelectSet(1)
  12.    
  13.     If Not oFace.SurfaceType = kCylinderSurface Then
  14.         MsgBox "A cylindrical face must be selected."
  15.         Exit Sub
  16.     End If
  17.    
  18.     Dim oCylinder As Cylinder
  19.     Set oCylinder = oFace.Geometry
  20.    
  21.     Dim params(1) As Double
  22.     params(0) = 0.5
  23.     params(1) = 0.5
  24.    
  25.     ' Get point on surface at param .5,.5
  26.    Dim points(2) As Double
  27.     Call oFace.Evaluator.GetPointAtParam(params, points)
  28.    
  29.     ' Create point object
  30.    Dim oPoint As point
  31.     Set oPoint = ThisApplication.TransientGeometry.CreatePoint(points(0), points(1), points(2))
  32.        
  33.     ' Get normal at this point
  34.    Dim normals(2) As Double
  35.     Call oFace.Evaluator.GetNormal(params, normals)
  36.    
  37.     ' Create normal vector object
  38.    Dim oNormal As Vector
  39.     Set oNormal = ThisApplication.TransientGeometry.CreateVector(normals(0), normals(1), normals(2))
  40.    
  41.     ' Scale vector by radius of the cylinder
  42.    oNormal.ScaleBy oCylinder.Radius
  43.    
  44.     ' Find the sampler point on the normal by adding the
  45.    ' scaled normal vector to the point at .5,.5 param.
  46.    Dim oSamplePoint As point
  47.     Set oSamplePoint = oPoint
  48.    
  49.     oSamplePoint.TranslateBy oNormal
  50.    
  51.     ' Check if the sample point lies on the cylinder axis.
  52.    ' If it does, we have a hollow face.
  53.  
  54.     ' Create a line describing the cylinder axis
  55.    Dim oAxisLine As Line
  56.     Set oAxisLine = ThisApplication.TransientGeometry.CreateLine _
  57.         (oCylinder.BasePoint, oCylinder.AxisVector.AsVector)
  58.        
  59.     'Create a line parallel to the axis passing thru the sample point.
  60.    Dim oSampleLine As Line
  61.     Set oSampleLine = ThisApplication.TransientGeometry.CreateLine _
  62.         (oSamplePoint, oCylinder.AxisVector.AsVector)
  63.        
  64.     If oSampleLine.IsColinearTo(oAxisLine) Then
  65.         MsgBox "Interior face."
  66.     Else
  67.         MsgBox "Exterior face."
  68.     End If
  69. End Sub
  70.  
  71.  
Не забывайте про правильное Форматирование кода на форуме
Создание и добавление Autodesk Screencast видео в сообщение на форуме
Если Вы задали вопрос и на форуме появился правильный ответ, то не забудьте про кнопку Решение