Получение выбранных элементов

Автор Тема: Получение выбранных элементов  (Прочитано 1784 раз)

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

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

  • ADN OPEN
  • ***
  • Сообщений: 210
  • Карма: 0
Добрый день!
Подскажите пожалуйста, как получить элементы модели, выбранные в дереве слева?
Спасибо!

Оффлайн mikazakov

  • ADN
  • *
  • Сообщений: 751
  • Карма: 195
  • Skype: mikazakov@mail.ru
Re: Получение выбранных элементов
« Ответ #1 : 23-06-2020, 20:12:32 »
BrowserNode.NativeObject
пример из хэлпа
Код - Visual Basic [Выбрать]
  1. Sub DataModelToBrowser()
  2.     ' Create a new part document, using the default part template.
  3.    Dim oPartDoc As PartDocument
  4.     Set oPartDoc = ThisApplication.Documents.Add(kPartDocumentObject)
  5.  
  6.     ' Set a reference to the component definition.
  7.    Dim oCompDef As PartComponentDefinition
  8.     Set oCompDef = oPartDoc.ComponentDefinition
  9.    
  10.     ' Create a new workplane parallel to the XY plane.
  11.    Dim oWorkPlane As WorkPlane
  12.     Set oWorkPlane = oCompDef.WorkPlanes.AddByPlaneAndOffset(oCompDef.WorkPlanes.Item(3), 1)
  13.    
  14.     ' Get the browser node definition associated with the work plane.
  15.    Dim oNativeBrowserNodeDef As NativeBrowserNodeDefinition
  16.     Set oNativeBrowserNodeDef = oPartDoc.BrowserPanes.GetNativeBrowserNodeDefinition(oWorkPlane)
  17.    
  18.     ' Get the top browser node of the model pane.
  19.    Dim oTopBrowserNode As BrowserNode
  20.     Set oTopBrowserNode = oPartDoc.BrowserPanes.ActivePane.TopNode
  21.    
  22.     ' Get the work plane browser node.
  23.    ' This assumes that only one node references the browser node definition.
  24.    ' An example of multiple nodes referencing a single definition is a shared
  25.    ' sketch. The browser may have multiple nodes that represent the same shared
  26.    ' sketch, but all of them reference the same definition.
  27.    Dim oWorkPlaneNode As BrowserNode
  28.     Set oWorkPlaneNode = oTopBrowserNode.AllReferencedNodes(oNativeBrowserNodeDef).Item(1)
  29.    
  30.     ' Get the browser node definition from the browser node.
  31.    Set oNativeBrowserNodeDef = Nothing
  32.     Set oNativeBrowserNodeDef = oWorkPlaneNode.BrowserNodeDefinition
  33.    
  34.     ' Get the work plane from the browser node definition.
  35.    Set oWorkPlane = Nothing
  36.     Set oWorkPlane = oNativeBrowserNodeDef.NativeObject
  37.    
  38.     ' Select the work plane to make sure we have the right object.
  39.    oPartDoc.SelectSet.Select oWorkPlane
  40.