├── Resources
├── Part.bmp
├── Arrow.bmp
├── Expand.png
├── Icon16.png
├── Icon32.png
├── Icon64.png
├── ArrowRed.bmp
├── Collapse.png
├── help_16.png
├── iFeature.bmp
├── OpenFolder.bmp
├── QuestionBox.bmp
└── ClosedFolder.bmp
├── AttributeHelperReadMe.pdf
├── AttributeHelperReadMe.docx
├── Autodesk.AttributeHelper.Inventor.addin
├── README.md
├── .gitattributes
├── AttributeHelper.X.manifest
├── .gitignore
├── AssemblyInfo.vb
├── AttributeHelper.sln
├── Installer
└── AttributeHelper.iss
├── EditAttribute.vb
├── My Project
├── Resources.Designer.vb
└── Resources.resx
├── EditAttribute.resx
├── EditAttribute.Designer.vb
├── StandardAddInServer.vb
├── AttributeHelper.vbproj
├── AttributeHelperDialog.resx
├── AttributeHelperDialog.Designer.vb
└── AttributeHelperDialog.vb
/Resources/Part.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/brianekins/AttributeHelper/HEAD/Resources/Part.bmp
--------------------------------------------------------------------------------
/Resources/Arrow.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/brianekins/AttributeHelper/HEAD/Resources/Arrow.bmp
--------------------------------------------------------------------------------
/Resources/Expand.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/brianekins/AttributeHelper/HEAD/Resources/Expand.png
--------------------------------------------------------------------------------
/Resources/Icon16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/brianekins/AttributeHelper/HEAD/Resources/Icon16.png
--------------------------------------------------------------------------------
/Resources/Icon32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/brianekins/AttributeHelper/HEAD/Resources/Icon32.png
--------------------------------------------------------------------------------
/Resources/Icon64.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/brianekins/AttributeHelper/HEAD/Resources/Icon64.png
--------------------------------------------------------------------------------
/Resources/ArrowRed.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/brianekins/AttributeHelper/HEAD/Resources/ArrowRed.bmp
--------------------------------------------------------------------------------
/Resources/Collapse.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/brianekins/AttributeHelper/HEAD/Resources/Collapse.png
--------------------------------------------------------------------------------
/Resources/help_16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/brianekins/AttributeHelper/HEAD/Resources/help_16.png
--------------------------------------------------------------------------------
/Resources/iFeature.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/brianekins/AttributeHelper/HEAD/Resources/iFeature.bmp
--------------------------------------------------------------------------------
/AttributeHelperReadMe.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/brianekins/AttributeHelper/HEAD/AttributeHelperReadMe.pdf
--------------------------------------------------------------------------------
/Resources/OpenFolder.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/brianekins/AttributeHelper/HEAD/Resources/OpenFolder.bmp
--------------------------------------------------------------------------------
/Resources/QuestionBox.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/brianekins/AttributeHelper/HEAD/Resources/QuestionBox.bmp
--------------------------------------------------------------------------------
/AttributeHelperReadMe.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/brianekins/AttributeHelper/HEAD/AttributeHelperReadMe.docx
--------------------------------------------------------------------------------
/Resources/ClosedFolder.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/brianekins/AttributeHelper/HEAD/Resources/ClosedFolder.bmp
--------------------------------------------------------------------------------
/Autodesk.AttributeHelper.Inventor.addin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/brianekins/AttributeHelper/HEAD/Autodesk.AttributeHelper.Inventor.addin
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # AttributeHelper
2 | **This is now obsolete.** However, there is a new version, with significant improvements available here: https://ekinssolutions.com/nifty_attributes/
3 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
4 | # Custom for Visual Studio
5 | *.cs diff=csharp
6 |
7 | # Standard to msysgit
8 | *.doc diff=astextplain
9 | *.DOC diff=astextplain
10 | *.docx diff=astextplain
11 | *.DOCX diff=astextplain
12 | *.dot diff=astextplain
13 | *.DOT diff=astextplain
14 | *.pdf diff=astextplain
15 | *.PDF diff=astextplain
16 | *.rtf diff=astextplain
17 | *.RTF diff=astextplain
18 |
--------------------------------------------------------------------------------
/AttributeHelper.X.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Local files
2 | *.suo
3 | *.user
4 | bin/*
5 | obj/*
6 | Readme.txt
7 | AttributeHelperSetup.exe
8 | AttributeHelperSetup.zip
9 |
10 |
11 | # Windows image file caches
12 | Thumbs.db
13 | ehthumbs.db
14 |
15 | # Folder config file
16 | Desktop.ini
17 |
18 | # Recycle Bin used on file shares
19 | $RECYCLE.BIN/
20 |
21 | # Windows Installer files
22 | *.cab
23 | *.msi
24 | *.msm
25 | *.msp
26 |
27 | # Windows shortcuts
28 | *.lnk
29 |
30 | # =========================
31 | # Operating System Files
32 | # =========================
33 |
34 | # OSX
35 | # =========================
36 |
37 | .DS_Store
38 | .AppleDouble
39 | .LSOverride
40 |
41 | # Thumbnails
42 | ._*
43 |
44 | # Files that might appear on external disk
45 | .Spotlight-V100
46 | .Trashes
47 |
48 | # Directories potentially created on remote AFP share
49 | .AppleDB
50 | .AppleDesktop
51 | Network Trash Folder
52 | Temporary Items
53 | .apdisk
54 |
--------------------------------------------------------------------------------
/AssemblyInfo.vb:
--------------------------------------------------------------------------------
1 | Imports System
2 | Imports System.Reflection
3 | Imports System.Runtime.InteropServices
4 |
5 | ' General Information about an assembly is controlled through the following
6 | ' set of attributes. Change these attribute values to modify the information
7 | ' associated with an assembly.
8 |
9 | ' Review the values of the assembly attributes
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | 'The following GUID is for the ID of the typelib if this project is exposed to COM
19 |
20 |
21 | ' Version information for an assembly consists of the following four values:
22 | '
23 | ' Major Version
24 | ' Minor Version
25 | ' Build Number
26 | ' Revision
27 | '
28 | ' You can specify all the values or you can default the Build and Revision Numbers
29 | ' by using the '*' as shown below:
30 |
31 |
32 |
--------------------------------------------------------------------------------
/AttributeHelper.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 11.00
3 | # Visual Studio 2010
4 | Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "AttributeHelper", "AttributeHelper.vbproj", "{06CE8A8A-129A-46C3-86EB-D24B4841CC5E}"
5 | EndProject
6 | Global
7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
8 | Debug|Any CPU = Debug|Any CPU
9 | Debug|x64 = Debug|x64
10 | Release|Any CPU = Release|Any CPU
11 | Release|x64 = Release|x64
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {06CE8A8A-129A-46C3-86EB-D24B4841CC5E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {06CE8A8A-129A-46C3-86EB-D24B4841CC5E}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {06CE8A8A-129A-46C3-86EB-D24B4841CC5E}.Debug|x64.ActiveCfg = Debug|x64
17 | {06CE8A8A-129A-46C3-86EB-D24B4841CC5E}.Debug|x64.Build.0 = Debug|x64
18 | {06CE8A8A-129A-46C3-86EB-D24B4841CC5E}.Release|Any CPU.ActiveCfg = Release|Any CPU
19 | {06CE8A8A-129A-46C3-86EB-D24B4841CC5E}.Release|Any CPU.Build.0 = Release|Any CPU
20 | {06CE8A8A-129A-46C3-86EB-D24B4841CC5E}.Release|x64.ActiveCfg = Release|x64
21 | {06CE8A8A-129A-46C3-86EB-D24B4841CC5E}.Release|x64.Build.0 = Release|x64
22 | EndGlobalSection
23 | GlobalSection(SolutionProperties) = preSolution
24 | HideSolutionNode = FALSE
25 | EndGlobalSection
26 | EndGlobal
27 |
--------------------------------------------------------------------------------
/Installer/AttributeHelper.iss:
--------------------------------------------------------------------------------
1 | ; Script generated by the Inno Setup Script Wizard.
2 | ; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
3 |
4 | #define MyAppName "Attribute Helper"
5 | #define MyAppVerName "Attribute Helper 2.5"
6 | #define MyAppPublisher "Brian Ekins"
7 | #define MyAppURL "http://blogs.autodesk.com/modthemachine/"
8 |
9 | [Setup]
10 | ; NOTE: The value of AppId uniquely identifies this application.
11 | ; Do not use the same AppId value in installers for other applications.
12 | ; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
13 | AppID={{3E1D3F56-BE91-44e0-B5D4-FA28110A11B3}
14 | AppName={#MyAppName}
15 | AppVerName={#MyAppVerName}
16 | AppPublisher={#MyAppPublisher}
17 | AppPublisherURL={#MyAppURL}
18 | AppSupportURL={#MyAppURL}
19 | AppUpdatesURL={#MyAppURL}
20 | ArchitecturesInstallIn64BitMode=x64
21 | DefaultDirName={commonappdata}\Autodesk\Inventor Addins\{#MyAppName}
22 | DefaultGroupName={#MyAppName}
23 | OutputDir=Setup
24 | OutputBaseFilename=AttributeHelperSetup
25 | Compression=lzma/Max
26 | SolidCompression=true
27 | DisableDirPage=yes
28 |
29 | [Languages]
30 | Name: english; MessagesFile: compiler:Default.isl
31 |
32 | [Files]
33 | Source: ..\bin\AttributeHelper.dll; DestDir: "{commonappdata}\Autodesk\Inventor Addins\{#MyAppName}"; Flags: ignoreversion;
34 | Source: ..\AttributeHelperReadMe.pdf; DestDir: "{commonappdata}\Autodesk\Inventor Addins\{#MyAppName}"; Flags: isreadme;
35 | Source: ..\Autodesk.AttributeHelper.Inventor.addin; DestDir: "{commonappdata}\Autodesk\Inventor Addins\{#MyAppName}";
36 |
37 | [Components]
38 |
39 | [Types]
40 |
--------------------------------------------------------------------------------
/EditAttribute.vb:
--------------------------------------------------------------------------------
1 | Imports System.Windows.Forms
2 |
3 | Public Class EditAttribute
4 | 'Public Sub New()
5 | ' ' This call is required by the designer.
6 | ' InitializeComponent()
7 |
8 | ' ' Add any initialization after the InitializeComponent() call.
9 |
10 | ' ' Set "String" as the initial default type.
11 | ' cboAttributeType.Text = "String"
12 | 'End Sub
13 |
14 | Public Property AttributeName() As String
15 | Get
16 | Return Me.txtAttributeName.Text
17 | End Get
18 | Set(ByVal value As String)
19 | Me.txtAttributeName.Text = value
20 | End Set
21 | End Property
22 |
23 | Public Property AttributeValue() As String
24 | Get
25 | Return Me.txtAttributeValue.Text
26 | End Get
27 | Set(ByVal value As String)
28 | Me.txtAttributeValue.Text = value
29 | End Set
30 | End Property
31 |
32 | Public Property AttributeType() As Inventor.ValueTypeEnum
33 | Get
34 | Select Case cboAttributeType.SelectedIndex
35 | Case 0
36 | Return Inventor.ValueTypeEnum.kStringType
37 | Case 1
38 | Return Inventor.ValueTypeEnum.kIntegerType
39 | Case 2
40 | Return Inventor.ValueTypeEnum.kDoubleType
41 | Case 3
42 | Return Inventor.ValueTypeEnum.kByteArrayType
43 | End Select
44 | End Get
45 |
46 | Set(ByVal value As Inventor.ValueTypeEnum)
47 | Select Case value
48 | Case Inventor.ValueTypeEnum.kStringType
49 | cboAttributeType.Text = "String"
50 | Case Inventor.ValueTypeEnum.kIntegerType
51 | cboAttributeType.Text = "Integer"
52 | Case Inventor.ValueTypeEnum.kDoubleType
53 | cboAttributeType.Text = "Double"
54 | Case Inventor.ValueTypeEnum.kByteArrayType
55 | cboAttributeType.Text = "Byte Array"
56 | End Select
57 | End Set
58 | End Property
59 |
60 | Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click
61 | Me.DialogResult = System.Windows.Forms.DialogResult.OK
62 | Me.Close()
63 | End Sub
64 |
65 | Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel_Button.Click
66 | Me.DialogResult = System.Windows.Forms.DialogResult.Cancel
67 | Me.Close()
68 | End Sub
69 |
70 | Public WriteOnly Property EditMode() As Boolean
71 | Set(ByVal value As Boolean)
72 | If value = True Then
73 | Me.Text = "Edit Attribute"
74 | Me.cboAttributeType.Enabled = False
75 | Else
76 | Me.Text = "Create Attribute"
77 | Me.txtAttributeName.Text = ""
78 | Me.txtAttributeValue.Text = ""
79 | Me.cboAttributeType.Text = "String"
80 | Me.cboAttributeType.Enabled = True
81 | End If
82 | End Set
83 | End Property
84 |
85 | Private Sub EditAttribute_Disposed(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Disposed
86 |
87 | End Sub
88 |
89 | Private Sub EditAttribute_Shown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shown
90 | If Me.Text = "Create Attribute" Then
91 | Me.txtAttributeName.Focus()
92 | Me.txtAttributeName.SelectAll()
93 | End If
94 | End Sub
95 |
96 |
97 | Private Sub EditAttribute_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
98 |
99 | End Sub
100 |
101 | Private Sub EditAttribute_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
102 |
103 | End Sub
104 |
105 | Private Sub cboAttributeType_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboAttributeType.SelectedIndexChanged
106 |
107 | End Sub
108 | End Class
109 |
--------------------------------------------------------------------------------
/My Project/Resources.Designer.vb:
--------------------------------------------------------------------------------
1 | '------------------------------------------------------------------------------
2 | '
3 | ' This code was generated by a tool.
4 | ' Runtime Version:4.0.30319.42000
5 | '
6 | ' Changes to this file may cause incorrect behavior and will be lost if
7 | ' the code is regenerated.
8 | '
9 | '------------------------------------------------------------------------------
10 |
11 | Option Strict On
12 | Option Explicit On
13 |
14 | Imports System
15 |
16 | Namespace My.Resources
17 |
18 | 'This class was auto-generated by the StronglyTypedResourceBuilder
19 | 'class via a tool like ResGen or Visual Studio.
20 | 'To add or remove a member, edit your .ResX file then rerun ResGen
21 | 'with the /str option, or rebuild your VS project.
22 | '''
23 | ''' A strongly-typed resource class, for looking up localized strings, etc.
24 | '''
25 | _
29 | Friend Module Resources
30 |
31 | Private resourceMan As Global.System.Resources.ResourceManager
32 |
33 | Private resourceCulture As Global.System.Globalization.CultureInfo
34 |
35 | '''
36 | ''' Returns the cached ResourceManager instance used by this class.
37 | '''
38 | _
39 | Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager
40 | Get
41 | If Object.ReferenceEquals(resourceMan, Nothing) Then
42 | Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("AttributeHelper.Resources", GetType(Resources).Assembly)
43 | resourceMan = temp
44 | End If
45 | Return resourceMan
46 | End Get
47 | End Property
48 |
49 | '''
50 | ''' Overrides the current thread's CurrentUICulture property for all
51 | ''' resource lookups using this strongly typed resource class.
52 | '''
53 | _
54 | Friend Property Culture() As Global.System.Globalization.CultureInfo
55 | Get
56 | Return resourceCulture
57 | End Get
58 | Set
59 | resourceCulture = value
60 | End Set
61 | End Property
62 |
63 | '''
64 | ''' Looks up a localized resource of type System.Drawing.Bitmap.
65 | '''
66 | Friend ReadOnly Property Collapse() As System.Drawing.Bitmap
67 | Get
68 | Dim obj As Object = ResourceManager.GetObject("Collapse", resourceCulture)
69 | Return CType(obj,System.Drawing.Bitmap)
70 | End Get
71 | End Property
72 |
73 | '''
74 | ''' Looks up a localized resource of type System.Drawing.Bitmap.
75 | '''
76 | Friend ReadOnly Property Expand() As System.Drawing.Bitmap
77 | Get
78 | Dim obj As Object = ResourceManager.GetObject("Expand", resourceCulture)
79 | Return CType(obj,System.Drawing.Bitmap)
80 | End Get
81 | End Property
82 |
83 | '''
84 | ''' Looks up a localized resource of type System.Drawing.Bitmap.
85 | '''
86 | Friend ReadOnly Property help_16() As System.Drawing.Bitmap
87 | Get
88 | Dim obj As Object = ResourceManager.GetObject("help_16", resourceCulture)
89 | Return CType(obj,System.Drawing.Bitmap)
90 | End Get
91 | End Property
92 |
93 | '''
94 | ''' Looks up a localized resource of type System.Drawing.Bitmap.
95 | '''
96 | Friend ReadOnly Property Icon16() As System.Drawing.Bitmap
97 | Get
98 | Dim obj As Object = ResourceManager.GetObject("Icon16", resourceCulture)
99 | Return CType(obj,System.Drawing.Bitmap)
100 | End Get
101 | End Property
102 |
103 | '''
104 | ''' Looks up a localized resource of type System.Drawing.Bitmap.
105 | '''
106 | Friend ReadOnly Property Icon32() As System.Drawing.Bitmap
107 | Get
108 | Dim obj As Object = ResourceManager.GetObject("Icon32", resourceCulture)
109 | Return CType(obj,System.Drawing.Bitmap)
110 | End Get
111 | End Property
112 | End Module
113 | End Namespace
114 |
--------------------------------------------------------------------------------
/EditAttribute.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/My Project/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 |
122 | ..\Resources\Collapse.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
123 |
124 |
125 | ..\Resources\Expand.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
126 |
127 |
128 | ..\Resources\help_16.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
129 |
130 |
131 | ..\Resources\Icon16.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
132 |
133 |
134 | ..\Resources\Icon32.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
135 |
136 |
--------------------------------------------------------------------------------
/EditAttribute.Designer.vb:
--------------------------------------------------------------------------------
1 | _
2 | Partial Class EditAttribute
3 | Inherits System.Windows.Forms.Form
4 |
5 | 'Form overrides dispose to clean up the component list.
6 | _
7 | Protected Overrides Sub Dispose(ByVal disposing As Boolean)
8 | Try
9 | If disposing AndAlso components IsNot Nothing Then
10 | components.Dispose()
11 | End If
12 | Finally
13 | MyBase.Dispose(disposing)
14 | End Try
15 | End Sub
16 |
17 | 'Required by the Windows Form Designer
18 | Private components As System.ComponentModel.IContainer
19 |
20 | 'NOTE: The following procedure is required by the Windows Form Designer
21 | 'It can be modified using the Windows Form Designer.
22 | 'Do not modify it using the code editor.
23 | _
24 | Private Sub InitializeComponent()
25 | Me.TableLayoutPanel1 = New System.Windows.Forms.TableLayoutPanel()
26 | Me.OK_Button = New System.Windows.Forms.Button()
27 | Me.Cancel_Button = New System.Windows.Forms.Button()
28 | Me.cboAttributeType = New System.Windows.Forms.ComboBox()
29 | Me.txtAttributeValue = New System.Windows.Forms.TextBox()
30 | Me.txtAttributeName = New System.Windows.Forms.TextBox()
31 | Me.Label3 = New System.Windows.Forms.Label()
32 | Me.Label2 = New System.Windows.Forms.Label()
33 | Me.Label1 = New System.Windows.Forms.Label()
34 | Me.TableLayoutPanel1.SuspendLayout()
35 | Me.SuspendLayout()
36 | '
37 | 'TableLayoutPanel1
38 | '
39 | Me.TableLayoutPanel1.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
40 | Me.TableLayoutPanel1.ColumnCount = 2
41 | Me.TableLayoutPanel1.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50.0!))
42 | Me.TableLayoutPanel1.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50.0!))
43 | Me.TableLayoutPanel1.Controls.Add(Me.OK_Button, 0, 0)
44 | Me.TableLayoutPanel1.Controls.Add(Me.Cancel_Button, 1, 0)
45 | Me.TableLayoutPanel1.Location = New System.Drawing.Point(106, 163)
46 | Me.TableLayoutPanel1.Name = "TableLayoutPanel1"
47 | Me.TableLayoutPanel1.RowCount = 1
48 | Me.TableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50.0!))
49 | Me.TableLayoutPanel1.Size = New System.Drawing.Size(146, 29)
50 | Me.TableLayoutPanel1.TabIndex = 0
51 | '
52 | 'OK_Button
53 | '
54 | Me.OK_Button.Anchor = System.Windows.Forms.AnchorStyles.None
55 | Me.OK_Button.Location = New System.Drawing.Point(3, 3)
56 | Me.OK_Button.Name = "OK_Button"
57 | Me.OK_Button.Size = New System.Drawing.Size(67, 23)
58 | Me.OK_Button.TabIndex = 3
59 | Me.OK_Button.Text = "OK"
60 | '
61 | 'Cancel_Button
62 | '
63 | Me.Cancel_Button.Anchor = System.Windows.Forms.AnchorStyles.None
64 | Me.Cancel_Button.DialogResult = System.Windows.Forms.DialogResult.Cancel
65 | Me.Cancel_Button.Location = New System.Drawing.Point(76, 3)
66 | Me.Cancel_Button.Name = "Cancel_Button"
67 | Me.Cancel_Button.Size = New System.Drawing.Size(67, 23)
68 | Me.Cancel_Button.TabIndex = 4
69 | Me.Cancel_Button.Text = "Cancel"
70 | '
71 | 'cboAttributeType
72 | '
73 | Me.cboAttributeType.AccessibleRole = System.Windows.Forms.AccessibleRole.Cursor
74 | Me.cboAttributeType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
75 | Me.cboAttributeType.Enabled = False
76 | Me.cboAttributeType.FormattingEnabled = True
77 | Me.cboAttributeType.Items.AddRange(New Object() {"String", "Integer", "Double", "Byte Array"})
78 | Me.cboAttributeType.Location = New System.Drawing.Point(46, 39)
79 | Me.cboAttributeType.Name = "cboAttributeType"
80 | Me.cboAttributeType.Size = New System.Drawing.Size(206, 21)
81 | Me.cboAttributeType.TabIndex = 1
82 | '
83 | 'txtAttributeValue
84 | '
85 | Me.txtAttributeValue.AcceptsReturn = True
86 | Me.txtAttributeValue.AcceptsTab = True
87 | Me.txtAttributeValue.Location = New System.Drawing.Point(46, 66)
88 | Me.txtAttributeValue.Multiline = True
89 | Me.txtAttributeValue.Name = "txtAttributeValue"
90 | Me.txtAttributeValue.Size = New System.Drawing.Size(206, 86)
91 | Me.txtAttributeValue.TabIndex = 2
92 | '
93 | 'txtAttributeName
94 | '
95 | Me.txtAttributeName.Location = New System.Drawing.Point(46, 12)
96 | Me.txtAttributeName.Name = "txtAttributeName"
97 | Me.txtAttributeName.Size = New System.Drawing.Size(206, 20)
98 | Me.txtAttributeName.TabIndex = 0
99 | '
100 | 'Label3
101 | '
102 | Me.Label3.AutoSize = True
103 | Me.Label3.Location = New System.Drawing.Point(12, 69)
104 | Me.Label3.Name = "Label3"
105 | Me.Label3.Size = New System.Drawing.Size(37, 13)
106 | Me.Label3.TabIndex = 2
107 | Me.Label3.Text = "Value:"
108 | '
109 | 'Label2
110 | '
111 | Me.Label2.AutoSize = True
112 | Me.Label2.Location = New System.Drawing.Point(12, 42)
113 | Me.Label2.Name = "Label2"
114 | Me.Label2.Size = New System.Drawing.Size(34, 13)
115 | Me.Label2.TabIndex = 1
116 | Me.Label2.Text = "Type:"
117 | '
118 | 'Label1
119 | '
120 | Me.Label1.AutoSize = True
121 | Me.Label1.Location = New System.Drawing.Point(12, 15)
122 | Me.Label1.Name = "Label1"
123 | Me.Label1.Size = New System.Drawing.Size(38, 13)
124 | Me.Label1.TabIndex = 0
125 | Me.Label1.Text = "Name:"
126 | '
127 | 'EditAttribute
128 | '
129 | Me.AcceptButton = Me.OK_Button
130 | Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
131 | Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
132 | Me.CancelButton = Me.Cancel_Button
133 | Me.ClientSize = New System.Drawing.Size(264, 204)
134 | Me.Controls.Add(Me.cboAttributeType)
135 | Me.Controls.Add(Me.TableLayoutPanel1)
136 | Me.Controls.Add(Me.txtAttributeValue)
137 | Me.Controls.Add(Me.txtAttributeName)
138 | Me.Controls.Add(Me.Label1)
139 | Me.Controls.Add(Me.Label3)
140 | Me.Controls.Add(Me.Label2)
141 | Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog
142 | Me.MaximizeBox = False
143 | Me.MinimizeBox = False
144 | Me.Name = "EditAttribute"
145 | Me.ShowInTaskbar = False
146 | Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent
147 | Me.Text = "Edit Attribute"
148 | Me.TableLayoutPanel1.ResumeLayout(False)
149 | Me.ResumeLayout(False)
150 | Me.PerformLayout()
151 |
152 | End Sub
153 | Friend WithEvents TableLayoutPanel1 As System.Windows.Forms.TableLayoutPanel
154 | Friend WithEvents OK_Button As System.Windows.Forms.Button
155 | Friend WithEvents Cancel_Button As System.Windows.Forms.Button
156 | Friend WithEvents cboAttributeType As System.Windows.Forms.ComboBox
157 | Friend WithEvents txtAttributeValue As System.Windows.Forms.TextBox
158 | Friend WithEvents txtAttributeName As System.Windows.Forms.TextBox
159 | Friend WithEvents Label3 As System.Windows.Forms.Label
160 | Friend WithEvents Label2 As System.Windows.Forms.Label
161 | Friend WithEvents Label1 As System.Windows.Forms.Label
162 |
163 | End Class
164 |
--------------------------------------------------------------------------------
/StandardAddInServer.vb:
--------------------------------------------------------------------------------
1 | Imports Inventor
2 | Imports System.Runtime.InteropServices
3 | Imports Microsoft.Win32
4 |
5 |
6 | Namespace AttributeHelper
7 | _
9 | Public Class StandardAddInServer
10 | Implements Inventor.ApplicationAddInServer
11 |
12 | ' Inventor application object.
13 | Private WithEvents m_attributeButtonDef As ButtonDefinition
14 | Private WithEvents m_UIEvents As UserInterfaceEvents
15 |
16 | #Region "ApplicationAddInServer Members"
17 |
18 | Public Sub Activate(ByVal addInSiteObject As Inventor.ApplicationAddInSite, ByVal firstTime As Boolean) Implements Inventor.ApplicationAddInServer.Activate
19 | ' Initialize AddIn members.
20 | g_inventorApplication = addInSiteObject.Application
21 |
22 | ' Get the button images.
23 | Dim smallIcon As IPictureDisp = PictureDispConverter.ToIPictureDisp(My.Resources.Icon16)
24 | Dim largeIcon As IPictureDisp = PictureDispConverter.ToIPictureDisp(My.Resources.Icon32)
25 |
26 | ' Create the button definition.
27 | m_attributeButtonDef = g_inventorApplication.CommandManager.ControlDefinitions.AddButtonDefinition("Attribute" & vbCr & "Helper", "ekinsAttributeHelper", CommandTypesEnum.kNonShapeEditCmdType, AddInGuid(Me.GetType), "View, edit, and create attributes.", "Attribute Helper", smallIcon, largeIcon)
28 |
29 | 'If firstTime Then
30 | AddToRibbon()
31 | 'End If
32 | End Sub
33 |
34 | Public Sub Deactivate() Implements Inventor.ApplicationAddInServer.Deactivate
35 | ' Release objects.
36 | Marshal.FinalReleaseComObject(g_inventorApplication)
37 | g_inventorApplication = Nothing
38 |
39 | If Not m_attributeButtonDef Is Nothing Then
40 | Marshal.FinalReleaseComObject(m_attributeButtonDef)
41 | End If
42 |
43 | If Not m_UIEvents Is Nothing Then
44 | Marshal.FinalReleaseComObject(m_UIEvents)
45 | m_UIEvents = Nothing
46 | End If
47 |
48 | System.GC.WaitForPendingFinalizers()
49 | System.GC.Collect()
50 | End Sub
51 |
52 | Public ReadOnly Property Automation() As Object Implements Inventor.ApplicationAddInServer.Automation
53 | Get
54 | Return Nothing
55 | End Get
56 | End Property
57 |
58 | Public Sub ExecuteCommand(ByVal commandID As Integer) Implements Inventor.ApplicationAddInServer.ExecuteCommand
59 | End Sub
60 | #End Region
61 |
62 | #Region "Ribbon related Members"
63 | Private Sub m_UIEvents_OnResetRibbonInterface(ByVal Context As Inventor.NameValueMap) Handles m_UIEvents.OnResetRibbonInterface
64 | AddToRibbon()
65 | End Sub
66 |
67 |
68 | Public Sub AddToRibbon()
69 | Try
70 | ' Create a panel on the Tools tab in all ribbons except zero doc and unknown.
71 | For Each ribbon As Inventor.Ribbon In g_inventorApplication.UserInterfaceManager.Ribbons
72 | Select Case ribbon.InternalName
73 | Case "Part", "Assembly", "Drawing", "Presentation", "iFeatures"
74 | Dim tab As RibbonTab = ribbon.RibbonTabs.Item("id_TabTools")
75 |
76 | Dim newPanel As RibbonPanel = tab.RibbonPanels.Add("Attributes", "ekinsAttributes", AddInGuid(Me.GetType))
77 |
78 | Call newPanel.CommandControls.AddButton(m_attributeButtonDef, True, True)
79 | End Select
80 | Next
81 | Catch ex As Exception
82 | MsgBox("Unexpected error adding Attribute Manager to the ribbon.")
83 | End Try
84 | End Sub
85 | #End Region
86 |
87 | Private Sub m_attributeButtonDef_OnExecute(ByVal Context As Inventor.NameValueMap) Handles m_attributeButtonDef.OnExecute
88 | If Not g_inventorApplication.ActiveEditDocument Is Nothing Then
89 | ' Stop the currently running command.
90 | g_inventorApplication.CommandManager.StopActiveCommand()
91 |
92 | Dim m_dialog As AttributeHelperDialog
93 | m_dialog = New AttributeHelperDialog
94 | m_dialog.InventorDocument = g_inventorApplication.ActiveEditDocument
95 | m_dialog.Show(New WindowWrapper(g_inventorApplication.MainFrameHWND))
96 | End If
97 | End Sub
98 |
99 |
100 | ' This property uses reflection to get the value for the GuidAttribute attached to the class.
101 | Public Shared ReadOnly Property AddInGuid(ByVal t As Type) As String
102 | Get
103 | Dim guid As String = ""
104 | Try
105 | Dim customAttributes() As Object = t.GetCustomAttributes(GetType(GuidAttribute), False)
106 | Dim guidAttribute As GuidAttribute = CType(customAttributes(0), GuidAttribute)
107 | guid = "{" + guidAttribute.Value.ToString() + "}"
108 | Finally
109 | AddInGuid = guid
110 | End Try
111 | End Get
112 | End Property
113 |
114 | End Class
115 |
116 | #Region "hWnd Wrapper Class"
117 | ' This class is used to wrap a Win32 hWnd as a .Net IWind32Window class.
118 | ' This is primarily used for parenting a dialog to the Inventor window.
119 | '
120 | ' For example:
121 | ' myForm.Show(New WindowWrapper(m_inventorApplication.MainFrameHWND))
122 | '
123 | Public Class WindowWrapper
124 | Implements System.Windows.Forms.IWin32Window
125 | Public Sub New(ByVal handle As IntPtr)
126 | _hwnd = handle
127 | End Sub
128 |
129 | Public ReadOnly Property Handle() As IntPtr _
130 | Implements System.Windows.Forms.IWin32Window.Handle
131 | Get
132 | Return _hwnd
133 | End Get
134 | End Property
135 |
136 | Private _hwnd As IntPtr
137 | End Class
138 | #End Region
139 |
140 | Public Module Globals
141 | ' Inventor application object.
142 | Public g_inventorApplication As Inventor.Application
143 |
144 | Public NotInheritable Class PictureDispConverter
145 | _
146 | Private Shared Function OleCreatePictureIndirect( _
147 | ByVal picdesc As Object, _
148 | ByRef iid As Guid, _
149 | ByVal fOwn As Boolean) As stdole.IPictureDisp
150 | End Function
151 |
152 | Shared iPictureDispGuid As Guid = GetType(stdole.IPictureDisp).GUID
153 |
154 | Private NotInheritable Class PICTDESC
155 | Private Sub New()
156 | End Sub
157 |
158 | 'Picture Types
159 | Public Const PICTYPE_UNINITIALIZED As Short = -1
160 | Public Const PICTYPE_NONE As Short = 0
161 | Public Const PICTYPE_BITMAP As Short = 1
162 | Public Const PICTYPE_METAFILE As Short = 2
163 | Public Const PICTYPE_ICON As Short = 3
164 | Public Const PICTYPE_ENHMETAFILE As Short = 4
165 |
166 | _
167 | Public Class Icon
168 | Friend cbSizeOfStruct As Integer = Marshal.SizeOf(GetType(PICTDESC.Icon))
169 | Friend picType As Integer = PICTDESC.PICTYPE_ICON
170 | Friend hicon As IntPtr = IntPtr.Zero
171 | Friend unused1 As Integer
172 | Friend unused2 As Integer
173 |
174 | Friend Sub New(ByVal icon As System.Drawing.Icon)
175 | Me.hicon = icon.ToBitmap().GetHicon()
176 | End Sub
177 | End Class
178 |
179 | _
180 | Public Class Bitmap
181 | Friend cbSizeOfStruct As Integer = Marshal.SizeOf(GetType(PICTDESC.Bitmap))
182 | Friend picType As Integer = PICTDESC.PICTYPE_BITMAP
183 | Friend hbitmap As IntPtr = IntPtr.Zero
184 | Friend hpal As IntPtr = IntPtr.Zero
185 | Friend unused As Integer
186 |
187 | Friend Sub New(ByVal bitmap As System.Drawing.Bitmap)
188 | Me.hbitmap = bitmap.GetHbitmap()
189 | End Sub
190 | End Class
191 | End Class
192 |
193 | Public Shared Function ToIPictureDisp(ByVal icon As System.Drawing.Icon) As stdole.IPictureDisp
194 | Dim pictIcon As New PICTDESC.Icon(icon)
195 | Return OleCreatePictureIndirect(pictIcon, iPictureDispGuid, True)
196 | End Function
197 |
198 | Public Shared Function ToIPictureDisp(ByVal bmp As System.Drawing.Bitmap) As stdole.IPictureDisp
199 | Dim pictBmp As New PICTDESC.Bitmap(bmp)
200 | Return OleCreatePictureIndirect(pictBmp, iPictureDispGuid, True)
201 | End Function
202 | End Class
203 |
204 | End Module
205 | End Namespace
206 |
207 |
--------------------------------------------------------------------------------
/AttributeHelper.vbproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | AnyCPU
6 | Library
7 |
8 |
9 |
10 |
11 | Windows
12 |
13 |
14 | {06CE8A8A-129A-46C3-86EB-D24B4841CC5E}
15 | 3.5
16 | On
17 | Binary
18 | Off
19 | On
20 | AttributeHelper
21 | v4.0
22 | publish\
23 | true
24 | Disk
25 | false
26 | Foreground
27 | 7
28 | Days
29 | false
30 | false
31 | true
32 | 0
33 | 1.0.0.%2a
34 | false
35 | false
36 | true
37 | Client
38 |
39 |
40 | ..\..\..\..\..\ProgramData\Autodesk\Inventor Addins\Attribute Helper\
41 | .xml
42 | true
43 | true
44 | true
45 | 42016,42017,42018,42019,42032,42353,42354,42355
46 | full
47 | false
48 | AllRules.ruleset
49 |
50 |
51 | bin\
52 | .xml
53 | false
54 | false
55 | true
56 | true
57 | 42016,42017,42018,42019,42032,42353,42354,42355
58 | none
59 | false
60 | AllRules.ruleset
61 |
62 |
63 | true
64 | true
65 | true
66 | ..\..\..\..\..\Program Files\Autodesk\Inventor 2012\Bin\
67 | xml.xml
68 | 42016,42017,42018,42019,42032,42353,42354,42355
69 | full
70 | x64
71 | ..\..\..\AppData\Roaming\Autodesk\ApplicationPlugins\Attribute Helper.bundle\Contents\AttributeHelper.dll.CodeAnalysisLog.xml
72 | true
73 | GlobalSuppressions.vb
74 | AllRules.ruleset
75 | ;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets
76 | ;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules
77 | false
78 |
79 |
80 | true
81 | bin\
82 | xml.xml
83 | true
84 | 42016,42017,42018,42019,42032,42353,42354,42355
85 | x64
86 | bin\Release\AttributeHelper.dll.CodeAnalysisLog.xml
87 | true
88 | GlobalSuppressions.vb
89 | AllRules.ruleset
90 | ;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets
91 | ;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules
92 | false
93 |
94 |
95 |
96 |
97 | False
98 | True
99 | ..\..\..\..\..\Windows\assembly\GAC_MSIL\Autodesk.Inventor.Interop\16.0.0.0__d84147f8b4276564\autodesk.inventor.interop.dll
100 |
101 |
102 |
103 | False
104 | ..\..\..\..\..\Program Files (x86)\Microsoft.NET\Primary Interop Assemblies\stdole.dll
105 |
106 |
107 | System
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 | AttributeHelperDialog.vb
122 |
123 |
124 | Form
125 |
126 |
127 | EditAttribute.vb
128 |
129 |
130 | Form
131 |
132 |
133 | True
134 | True
135 | Resources.resx
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 | AttributeHelperDialog.vb
151 |
152 |
153 | EditAttribute.vb
154 |
155 |
156 | My.Resources
157 | VbMyResourcesResXFileCodeGenerator
158 | Resources.Designer.vb
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 | False
170 | .NET Framework 3.5 SP1 Client Profile
171 | false
172 |
173 |
174 | False
175 | .NET Framework 3.5 SP1
176 | true
177 |
178 |
179 | False
180 | Windows Installer 3.1
181 | true
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 | call "%25VS110COMNTOOLS%25vsvars32"
198 | mt.exe -manifest "$(ProjectDir)AttributeHelper.X.manifest" -outputresource:"$(TargetPath)";#2
199 |
200 | copy "$(ProjectDir)Autodesk.AttributeHelper.Inventor.addin" "$(TargetDir)"
201 |
202 |
--------------------------------------------------------------------------------
/AttributeHelperDialog.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 | 17, 17
122 |
123 |
124 |
125 | AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
126 | LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
127 | ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAD4
128 | CAAAAk1TRnQBSQFMAgEBBQEAASwBAAEsAQABEAEAARABAAT/ASEBAAj/AUIBTQE2BwABNgMAASgDAAFA
129 | AwABIAMAAQEBAAEgBgABIBIAJP8DAAH/AwAV/8AAJP8DAAX/AwAR/8AAEP8DAA3/AwAF/wIAAe0B/wMA
130 | Ef/AABD/AwAB/wMACf8DAAH/AgAB7QH/AwAV/8AAEP8DAAH/AgAB7QH/AwAB/wMAAf8CAAHtBf8DABX/
131 | wAAQ/wMABf8CAAHtAf8DAAX/AwAZ/8AAEP8DAAH/AgAB7QX/AgAB7QH/AwAB/wMAAf8DAAH/AwAB/wMA
132 | Df/AABD/AwAF/wIAAe0F/wIAAe0F/wIAAe0B/wMAEf/AABD/AwAB/wIAAe0F/wIAAe0F/wIAAe0B/wMA
133 | Ff/AABD/AwAF/wIAAe0F/wIAAe0B/wMAGf/AABD/AwAB/wIAAe0F/wIAAe0B/wMAHf/AABD/AwAF/wIA
134 | Ae0B/wMAIf/AABD/AwAB/wIAAe0B/wMAJf/AABD/AwAB/wMAKf/AABD/AwAt/8AAQP/AAOT/AwAB/wMA
135 | vf8DAAH/AwA1/wMABf8DABn/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMA
136 | Af8DAAH/AwAB/wMADf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMA
137 | Af8DAA3/A4AB/wOAAf8DgAH/A4AB/wOAAf8DgAH/AwAB/wEAA/8DAAH/A4Ad/wMADf8DAAn/AwAV/wOA
138 | Af8DgAH/A4AB/wOAAf8DgAH/A4AB/wOAAf8DgAH/A4AB/wOAAf8DgAH/A4AB/wOAAf8DgAH/AwAJ/wOA
139 | Af8DgAH/A4AB/wOAAf8DgAH/A4AB/wOAAf8DgAH/A4AB/wOAAf8DgAH/A4AB/wMAAf8DAAn/AwAB/wMA
140 | Af8DAAH/AwAB/wMAAf8DAAH/AwAJ/wMAAf8DAAH/A4AZ/wMAAf8DAAn/AwAF/wMAGf8DgAX/AQAD/wPA
141 | Af8BAAP/A8AB/wEAA/8DwAH/AQAD/wPAAf8BAAP/A8AB/wEAA/8DgAH/AwAJ/wOABf8BAAP/A8AB/wEA
142 | A/8DwAH/AQAD/wPAAf8BAAP/A8AB/wEAA/8DgAH/AwAB/wMABf8DAA3/AQAH/wEAB/8BAA//AwAB/wOA
143 | Ff8DAAX/AwAB/wMACf8DABn/A4AF/wPAAf8BAAP/A8AB/wEAA/8DwAH/AQAD/wPAAf8BAAP/A8AB/wEA
144 | A/8DwAH/A4AB/wMABf8DgAX/AQAD/wPAAf8BAAP/A8AB/wEAA/8DwAH/AQAD/wPAAf8BAAP/A8AB/wMA
145 | Af8DgAH/AwAF/wMABf8BAA//AYACAAH/AYACAAn/AQAH/wMAAf8DgBX/AwAJ/wMABf8DAB3/A4AF/wEA
146 | A/8DwAH/AQAD/wPAAf8BAAP/A8AB/wEAA/8DwAH/AQAD/wPAAf8BAAP/A4AB/wMABf8DgAX/A8AB/wEA
147 | A/8DwAH/AQAD/wPAAf8BAAP/A8AB/wEAA/8DwAH/A4AB/wMAAf8DgAH/AwAF/wMADf8BAA//AQAP/wMA
148 | Af8DgBX/AwAN/wMAAf8DAAH/AwAB/wMAAf8DABH/A4AF/wPAAf8BAAP/A8AB/wEAA/8DwAH/AQAD/wPA
149 | Af8BAAP/A8AB/wEAA/8DwAH/A4AB/wMAAf8DgAX/A8AB/wEAA/8DwAH/AQAD/wPAAf8BAAP/A8AB/wEA
150 | A/8DwAH/AQAD/wMAAf8DgAH/A4AB/wMABf8DAAX/AQAP/wGAAgAB/wOACf8BAAf/AwAB/wOAFf8DABn/
151 | AwAV/wOABf8BAAP/A8AB/wEAA/8DwAH/AQAD/wPAAf8BAAP/A8AB/wEAA/8DwAH/AQAD/wOAAf8DAAH/
152 | A4Ap/wOAAf8DAAH/A8AB/wOAAf8DAAX/AwAN/wEAB/8DgAH/AYACAAH/A8AN/wMAAf8DgBX/AwAV/wMA
153 | Gf8DgAX/A8AB/wEAA/8DwAH/AQAD/wPAAf8BAAP/A8AB/wEAA/8DwAH/AQAD/wPAAf8DgAH/AwAB/wOA
154 | Af8DgAH/A4AB/wOAAf8DgAH/A4AB/wOAAf8DgAH/A4AB/wOAAf8DgAH/A4AB/wOAAf8BAAP/A4AB/wMA
155 | Bf8DAAX/AQAP/wEAA/8DgAH/AYACAAH/A4AB/wEAB/8DAAH/A4AV/wMAEf8DAB3/A4AF/wEAA/8DwAH/
156 | AQAD/wPAAf8BAAP/A8AB/wEAA/8DwAH/AQAD/wPAAf8BAAP/A4AB/wMABf8DgAX/A8AB/wEAA/8DwAH/
157 | AQAD/wPAAf8BAAP/A8AB/wEAA/8DwAH/AQAD/wPAAf8DgAH/AwAF/wMADf8BgAIAAf8DgAn/AYACAAH/
158 | AYACAAn/AwAB/wOAFf8DAA3/AwAh/wOAMf8DgAH/AwAF/wOABf8BAAP/A8AB/wEAA/8DwAH/AQAD/wPA
159 | Ff8DgAH/AwAF/wMABf8BAAf/AYACAAH/AYACAAH/AQAD/wPAAf8BgAIAAf8BgAIAAf8BAAf/AwAB/wOA
160 | Ff8DAAn/AwAl/wOAAf8DwAH/AQAD/wPAAf8BAAP/A8AB/wEAA/8DwAH/A4AB/wOAAf8DgAH/A4AB/wOA
161 | Af8DgAn/A4AF/wPAAf8BAAP/A8AB/wEAA/8DwAX/A4AB/wOAAf8DgAH/A4AB/wOAAf8DgAn/AwAN/wPA
162 | Af8BgAIAAf8BgAIAAf8BgAIAAf8BgAIAAf8DwAn/AwAB/wOAFf8DAAX/AwAt/wOAAf8DwAH/AQAD/wPA
163 | Af8BAAP/A8AB/wOAJf8DgBX/A4Ah/wMABf8BAA//AQAP/wEAB/8DAAH/A4AV/wMAAf8DADX/A4AB/wOA
164 | Af8DgAH/A4AB/wOALf8DgAH/A4AB/wOAAf8DgAH/A4Al/wMADf8BAA//AQAP/wMAGf8DALX/AwAB/wMA
165 | Af8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMATf8BQgFNAT4HAAE+AwABKAMAAUADAAEg
166 | AwABAQEAAQEGAAEBFgAD//8AAgAL
167 |
168 |
169 |
170 | 121, 17
171 |
172 |
173 | 220, 17
174 |
175 |
176 | 32
177 |
178 |
--------------------------------------------------------------------------------
/AttributeHelperDialog.Designer.vb:
--------------------------------------------------------------------------------
1 | _
2 | Partial Class AttributeHelperDialog
3 | Inherits System.Windows.Forms.Form
4 |
5 | 'Form overrides dispose to clean up the component list.
6 | _
7 | Protected Overrides Sub Dispose(ByVal disposing As Boolean)
8 | Try
9 | If disposing AndAlso components IsNot Nothing Then
10 | components.Dispose()
11 | End If
12 | Finally
13 | MyBase.Dispose(disposing)
14 | End Try
15 | End Sub
16 |
17 | 'Required by the Windows Form Designer
18 | Private components As System.ComponentModel.IContainer
19 |
20 | 'NOTE: The following procedure is required by the Windows Form Designer
21 | 'It can be modified using the Windows Form Designer.
22 | 'Do not modify it using the code editor.
23 | _
24 | Private Sub InitializeComponent()
25 | Me.components = New System.ComponentModel.Container()
26 | Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(AttributeHelperDialog))
27 | Me.OK_Button = New System.Windows.Forms.Button()
28 | Me.Cancel_Button = New System.Windows.Forms.Button()
29 | Me.ImageList = New System.Windows.Forms.ImageList(Me.components)
30 | Me.ctxMenu = New System.Windows.Forms.ContextMenuStrip(Me.components)
31 | Me.AddAttributeSetToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
32 | Me.DeleteAllAttributesToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
33 | Me.AddAttributeToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
34 | Me.EditNameToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
35 | Me.DeleteAttributeSetToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
36 | Me.EditAttributeToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
37 | Me.DeleteAttributeToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
38 | Me.lblVersion = New System.Windows.Forms.Label()
39 | Me.treeView = New System.Windows.Forms.TreeView()
40 | Me.btnHelp = New System.Windows.Forms.Button()
41 | Me.btnExpandAll = New System.Windows.Forms.Button()
42 | Me.btnCollapseAll = New System.Windows.Forms.Button()
43 | Me.toolTip = New System.Windows.Forms.ToolTip(Me.components)
44 | Me.ctxMenu.SuspendLayout()
45 | Me.SuspendLayout()
46 | '
47 | 'OK_Button
48 | '
49 | Me.OK_Button.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
50 | Me.OK_Button.Location = New System.Drawing.Point(182, 427)
51 | Me.OK_Button.Name = "OK_Button"
52 | Me.OK_Button.Size = New System.Drawing.Size(67, 24)
53 | Me.OK_Button.TabIndex = 0
54 | Me.OK_Button.Text = "OK"
55 | '
56 | 'Cancel_Button
57 | '
58 | Me.Cancel_Button.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
59 | Me.Cancel_Button.DialogResult = System.Windows.Forms.DialogResult.Cancel
60 | Me.Cancel_Button.Location = New System.Drawing.Point(255, 427)
61 | Me.Cancel_Button.Name = "Cancel_Button"
62 | Me.Cancel_Button.Size = New System.Drawing.Size(67, 24)
63 | Me.Cancel_Button.TabIndex = 1
64 | Me.Cancel_Button.Text = "Cancel"
65 | '
66 | 'ImageList
67 | '
68 | Me.ImageList.ImageStream = CType(resources.GetObject("ImageList.ImageStream"), System.Windows.Forms.ImageListStreamer)
69 | Me.ImageList.TransparentColor = System.Drawing.Color.Transparent
70 | Me.ImageList.Images.SetKeyName(0, "ClosedFolder")
71 | Me.ImageList.Images.SetKeyName(1, "OpenFolder")
72 | Me.ImageList.Images.SetKeyName(2, "Attribute")
73 | Me.ImageList.Images.SetKeyName(3, "ArrowWhite")
74 | Me.ImageList.Images.SetKeyName(4, "ArrowRed")
75 | '
76 | 'ctxMenu
77 | '
78 | Me.ctxMenu.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.AddAttributeSetToolStripMenuItem, Me.DeleteAllAttributesToolStripMenuItem, Me.AddAttributeToolStripMenuItem, Me.EditNameToolStripMenuItem, Me.DeleteAttributeSetToolStripMenuItem, Me.EditAttributeToolStripMenuItem, Me.DeleteAttributeToolStripMenuItem})
79 | Me.ctxMenu.Name = "ctxMenu"
80 | Me.ctxMenu.Size = New System.Drawing.Size(222, 158)
81 | '
82 | 'AddAttributeSetToolStripMenuItem
83 | '
84 | Me.AddAttributeSetToolStripMenuItem.Name = "AddAttributeSetToolStripMenuItem"
85 | Me.AddAttributeSetToolStripMenuItem.Size = New System.Drawing.Size(221, 22)
86 | Me.AddAttributeSetToolStripMenuItem.Text = "Add attribute set"
87 | '
88 | 'DeleteAllAttributesToolStripMenuItem
89 | '
90 | Me.DeleteAllAttributesToolStripMenuItem.Name = "DeleteAllAttributesToolStripMenuItem"
91 | Me.DeleteAllAttributesToolStripMenuItem.Size = New System.Drawing.Size(221, 22)
92 | Me.DeleteAllAttributesToolStripMenuItem.Text = "Delete all sets and attributes"
93 | '
94 | 'AddAttributeToolStripMenuItem
95 | '
96 | Me.AddAttributeToolStripMenuItem.Name = "AddAttributeToolStripMenuItem"
97 | Me.AddAttributeToolStripMenuItem.Size = New System.Drawing.Size(221, 22)
98 | Me.AddAttributeToolStripMenuItem.Text = "Add attribute"
99 | '
100 | 'EditNameToolStripMenuItem
101 | '
102 | Me.EditNameToolStripMenuItem.Name = "EditNameToolStripMenuItem"
103 | Me.EditNameToolStripMenuItem.Size = New System.Drawing.Size(221, 22)
104 | Me.EditNameToolStripMenuItem.Text = "Edit name"
105 | '
106 | 'DeleteAttributeSetToolStripMenuItem
107 | '
108 | Me.DeleteAttributeSetToolStripMenuItem.Name = "DeleteAttributeSetToolStripMenuItem"
109 | Me.DeleteAttributeSetToolStripMenuItem.Size = New System.Drawing.Size(221, 22)
110 | Me.DeleteAttributeSetToolStripMenuItem.Text = "Delete"
111 | '
112 | 'EditAttributeToolStripMenuItem
113 | '
114 | Me.EditAttributeToolStripMenuItem.Name = "EditAttributeToolStripMenuItem"
115 | Me.EditAttributeToolStripMenuItem.Size = New System.Drawing.Size(221, 22)
116 | Me.EditAttributeToolStripMenuItem.Text = "Edit"
117 | '
118 | 'DeleteAttributeToolStripMenuItem
119 | '
120 | Me.DeleteAttributeToolStripMenuItem.Name = "DeleteAttributeToolStripMenuItem"
121 | Me.DeleteAttributeToolStripMenuItem.Size = New System.Drawing.Size(221, 22)
122 | Me.DeleteAttributeToolStripMenuItem.Text = "Delete"
123 | '
124 | 'lblVersion
125 | '
126 | Me.lblVersion.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
127 | Me.lblVersion.AutoSize = True
128 | Me.lblVersion.Font = New System.Drawing.Font("Microsoft Sans Serif", 6.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
129 | Me.lblVersion.Location = New System.Drawing.Point(270, -1)
130 | Me.lblVersion.Name = "lblVersion"
131 | Me.lblVersion.Size = New System.Drawing.Size(55, 12)
132 | Me.lblVersion.TabIndex = 2
133 | Me.lblVersion.Text = "Version: x.x"
134 | '
135 | 'treeView
136 | '
137 | Me.treeView.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
138 | Or System.Windows.Forms.AnchorStyles.Left) _
139 | Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
140 | Me.treeView.HideSelection = False
141 | Me.treeView.ImageIndex = 0
142 | Me.treeView.ImageList = Me.ImageList
143 | Me.treeView.Location = New System.Drawing.Point(12, 12)
144 | Me.treeView.Name = "treeView"
145 | Me.treeView.SelectedImageIndex = 0
146 | Me.treeView.Size = New System.Drawing.Size(310, 409)
147 | Me.treeView.TabIndex = 1
148 | '
149 | 'btnHelp
150 | '
151 | Me.btnHelp.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left), System.Windows.Forms.AnchorStyles)
152 | Me.btnHelp.Image = Global.AttributeHelper.My.Resources.Resources.help_16
153 | Me.btnHelp.Location = New System.Drawing.Point(70, 427)
154 | Me.btnHelp.Name = "btnHelp"
155 | Me.btnHelp.Size = New System.Drawing.Size(24, 24)
156 | Me.btnHelp.TabIndex = 3
157 | Me.toolTip.SetToolTip(Me.btnHelp, "Help")
158 | '
159 | 'btnExpandAll
160 | '
161 | Me.btnExpandAll.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left), System.Windows.Forms.AnchorStyles)
162 | Me.btnExpandAll.Image = Global.AttributeHelper.My.Resources.Resources.Expand
163 | Me.btnExpandAll.Location = New System.Drawing.Point(12, 427)
164 | Me.btnExpandAll.Name = "btnExpandAll"
165 | Me.btnExpandAll.Size = New System.Drawing.Size(24, 24)
166 | Me.btnExpandAll.TabIndex = 0
167 | Me.toolTip.SetToolTip(Me.btnExpandAll, "Expand Tree")
168 | '
169 | 'btnCollapseAll
170 | '
171 | Me.btnCollapseAll.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left), System.Windows.Forms.AnchorStyles)
172 | Me.btnCollapseAll.Image = Global.AttributeHelper.My.Resources.Resources.Collapse
173 | Me.btnCollapseAll.Location = New System.Drawing.Point(41, 427)
174 | Me.btnCollapseAll.Name = "btnCollapseAll"
175 | Me.btnCollapseAll.Size = New System.Drawing.Size(24, 24)
176 | Me.btnCollapseAll.TabIndex = 0
177 | Me.toolTip.SetToolTip(Me.btnCollapseAll, "Collapse Tree")
178 | '
179 | 'AttributeHelperDialog
180 | '
181 | Me.AcceptButton = Me.OK_Button
182 | Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
183 | Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
184 | Me.CancelButton = Me.Cancel_Button
185 | Me.ClientSize = New System.Drawing.Size(334, 462)
186 | Me.Controls.Add(Me.btnHelp)
187 | Me.Controls.Add(Me.treeView)
188 | Me.Controls.Add(Me.lblVersion)
189 | Me.Controls.Add(Me.Cancel_Button)
190 | Me.Controls.Add(Me.OK_Button)
191 | Me.Controls.Add(Me.btnExpandAll)
192 | Me.Controls.Add(Me.btnCollapseAll)
193 | Me.MaximizeBox = False
194 | Me.MinimizeBox = False
195 | Me.MinimumSize = New System.Drawing.Size(350, 500)
196 | Me.Name = "AttributeHelperDialog"
197 | Me.ShowInTaskbar = False
198 | Me.StartPosition = System.Windows.Forms.FormStartPosition.Manual
199 | Me.Text = "Attribute Helper"
200 | Me.ctxMenu.ResumeLayout(False)
201 | Me.ResumeLayout(False)
202 | Me.PerformLayout()
203 |
204 | End Sub
205 | Friend WithEvents OK_Button As System.Windows.Forms.Button
206 | Friend WithEvents Cancel_Button As System.Windows.Forms.Button
207 | Friend WithEvents ImageList As System.Windows.Forms.ImageList
208 | Friend WithEvents ctxMenu As System.Windows.Forms.ContextMenuStrip
209 | Friend WithEvents DeleteAttributeSetToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
210 | Friend WithEvents EditAttributeToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
211 | Friend WithEvents AddAttributeToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
212 | Friend WithEvents AddAttributeSetToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
213 | Friend WithEvents DeleteAllAttributesToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
214 | Friend WithEvents EditNameToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
215 | Friend WithEvents DeleteAttributeToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
216 | Friend WithEvents btnExpandAll As System.Windows.Forms.Button
217 | Friend WithEvents btnCollapseAll As System.Windows.Forms.Button
218 | Friend WithEvents lblVersion As System.Windows.Forms.Label
219 | Friend WithEvents treeView As Windows.Forms.TreeView
220 | Friend WithEvents btnHelp As Windows.Forms.Button
221 | Friend WithEvents toolTip As Windows.Forms.ToolTip
222 | End Class
223 |
--------------------------------------------------------------------------------
/AttributeHelperDialog.vb:
--------------------------------------------------------------------------------
1 | Imports System.Windows.Forms
2 |
3 | Public Class AttributeHelperDialog
4 | Private m_InventorDoc As Inventor.Document = Nothing
5 | Private m_editsMade As Boolean = False
6 | Private m_Entities As MyEntities
7 | Private m_HighlightSet As Inventor.HighlightSet
8 | Private m_NodeCount As Integer = 0
9 | Private m_ObjectList As New Collection
10 | Private m_SelectedEntity As Object
11 | Private m_LastMousePosition As System.Drawing.Point
12 |
13 | Private WithEvents m_DocEvents As Inventor.DocumentEvents
14 | Private WithEvents m_InputEvents As Inventor.UserInputEvents
15 | Private WithEvents m_AddAttributeSetButtonDef As Inventor.ButtonDefinition
16 | Private WithEvents m_FindAttributeInDialogButtonDef As Inventor.ButtonDefinition
17 |
18 |
19 |
20 | Public Property InventorDocument() As Inventor.Document
21 | Get
22 | Return m_InventorDoc
23 | End Get
24 | Set(ByVal value As Inventor.Document)
25 | m_InventorDoc = value
26 | End Set
27 | End Property
28 |
29 | Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click
30 | Try
31 | ' Apply the results.
32 | If m_Entities.HasChanges Then
33 | For Each entity As MyEntity In m_Entities
34 | UpdateEntity(entity)
35 | Next
36 | End If
37 |
38 | CleanUp()
39 | Me.DialogResult = System.Windows.Forms.DialogResult.OK
40 | Me.Close()
41 | Catch ex As Exception
42 | MsgBox("Unexepected failure exiting the form with OK.")
43 | End Try
44 | End Sub
45 |
46 | Private Sub UpdateEntity(ByVal Entity As MyEntity)
47 | Try
48 | For Each attribSet As MyAttributeSet In Entity.AttributeSets
49 | Dim invAttribSet As Inventor.AttributeSet
50 |
51 | ' Check for any new attribute sets.
52 | If attribSet.IsNew And Not attribSet.IsDeleted Then
53 | invAttribSet = Entity.Entity.AttributeSets.Add(attribSet.Name)
54 |
55 | ' Add its attributes.
56 | For Each attrib As MyAttribute In attribSet
57 | invAttribSet.Add(attrib.Name, attrib.AttributeType, attrib.Value)
58 | Next
59 | ElseIf attribSet.IsDeleted Then
60 | If Not attribSet.InventorAttributeSet Is Nothing Then
61 | attribSet.InventorAttributeSet.Delete()
62 | End If
63 | ' Entity.Entity.AttributeSets.Item(attribSet.Name).Delete()
64 | ElseIf attribSet.IsEdited Then
65 | invAttribSet = Entity.Entity.AttributeSets.item(attribSet.OriginalName)
66 |
67 | If invAttribSet.Name <> attribSet.Name Then
68 | invAttribSet.Name = attribSet.Name
69 | End If
70 |
71 | ' Update the individual attributes.
72 | For Each attrib As MyAttribute In attribSet
73 | If attrib.IsDeleted Then
74 | ' Delete the attribute.
75 | invAttribSet.Item(attrib.Name).Delete()
76 | ElseIf attrib.IsNew Then
77 | ' Create the attribute.
78 | invAttribSet.Add(attrib.Name, attrib.AttributeType, attrib.Value)
79 | ElseIf attrib.IsEdited Then
80 | Dim invAttrib As Inventor.Attribute = invAttribSet.Item(attrib.OriginalName)
81 |
82 | If invAttrib.Name <> attrib.Name Then
83 | invAttrib.Name = attrib.Name
84 | End If
85 |
86 | invAttrib.Value = attrib.Value
87 | End If
88 | Next
89 | End If
90 | Next
91 | Catch ex As Exception
92 | MsgBox("Unexepected Failure while updating the attribute information.")
93 | End Try
94 | End Sub
95 |
96 | Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel_Button.Click
97 | Try
98 | If m_Entities.HasChanges Then
99 | If MsgBox("Canceling will lose the edits that have been made. Do you want to continue and loose them?", MsgBoxStyle.Question + MsgBoxStyle.YesNo) = MsgBoxResult.No Then
100 | Exit Sub
101 | End If
102 | End If
103 |
104 | CleanUp()
105 | Me.DialogResult = System.Windows.Forms.DialogResult.Cancel
106 | Me.Close()
107 | Catch ex As Exception
108 | MsgBox("Unexepected failure exiting the form with Cancel.")
109 | End Try
110 | End Sub
111 |
112 | Private Sub CleanUp()
113 | If Not m_HighlightSet Is Nothing Then
114 | m_HighlightSet.Clear()
115 | System.Runtime.InteropServices.Marshal.ReleaseComObject(m_HighlightSet)
116 | m_HighlightSet = Nothing
117 | End If
118 |
119 | If Not m_DocEvents Is Nothing Then
120 | System.Runtime.InteropServices.Marshal.ReleaseComObject(m_DocEvents)
121 | m_DocEvents = Nothing
122 | End If
123 |
124 | If Not m_InputEvents Is Nothing Then
125 | System.Runtime.InteropServices.Marshal.ReleaseComObject(m_InputEvents)
126 | m_InputEvents = Nothing
127 | End If
128 |
129 | If Not m_AddAttributeSetButtonDef Is Nothing Then
130 | System.Runtime.InteropServices.Marshal.ReleaseComObject(m_AddAttributeSetButtonDef)
131 | m_AddAttributeSetButtonDef = Nothing
132 | End If
133 |
134 | If Not m_FindAttributeInDialogButtonDef Is Nothing Then
135 | System.Runtime.InteropServices.Marshal.ReleaseComObject(m_FindAttributeInDialogButtonDef)
136 | m_FindAttributeInDialogButtonDef = Nothing
137 | End If
138 |
139 | Me.InventorDocument = Nothing
140 |
141 | System.GC.WaitForPendingFinalizers()
142 | System.GC.Collect()
143 |
144 | m_Entities = Nothing
145 | m_ObjectList = Nothing
146 | End Sub
147 |
148 | Private Sub AttributeHelperDialog_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
149 | Try
150 | Dim version As System.Version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version
151 | lblVersion.Text = "Version: " & version.Major & "." & version.Minor
152 |
153 | If Not Me.InventorDocument Is Nothing Then
154 | Me.Left = Me.InventorDocument.Parent.Left + 25
155 | Me.Top = Me.InventorDocument.Parent.Top + 25
156 |
157 | Dim commandManager As Inventor.CommandManager = Me.InventorDocument.Parent.CommandManager
158 | Try
159 | m_AddAttributeSetButtonDef = commandManager.ControlDefinitions.Item("ekinsAddAttributeSet")
160 | m_FindAttributeInDialogButtonDef = commandManager.ControlDefinitions.Item("ekinsFindInDialog")
161 | Catch ex As Exception
162 | m_AddAttributeSetButtonDef = commandManager.ControlDefinitions.AddButtonDefinition("Add Attribute Set", "ekinsAddAttributeSet", Inventor.CommandTypesEnum.kNonShapeEditCmdType, "{5e98b9dd-6c1a-4ce8-b157-428250cc5e5e}", "Add an attribute set to the selected entity.", "Add Attribute Set")
163 | m_FindAttributeInDialogButtonDef = commandManager.ControlDefinitions.AddButtonDefinition("Find Object in Dialog", "ekinsFindInDialog", Inventor.CommandTypesEnum.kNonShapeEditCmdType, "{5e98b9dd-6c1a-4ce8-b157-428250cc5e5e}", "Find this entity in the Attribute Helper dialog.", "Find Object in Dialog")
164 | commandManager.CommandCategories.Item("FWxContextMenuCategory").Add(m_AddAttributeSetButtonDef)
165 | commandManager.CommandCategories.Item("FWxContextMenuCategory").Add(m_FindAttributeInDialogButtonDef)
166 | End Try
167 |
168 | Me.InventorDocument.Parent.CommandManager.ControlDefinitions.Item("AppSelectNorthwestArrowCmd").Execute()
169 | m_DocEvents = Me.InventorDocument.DocumentEvents
170 | m_InputEvents = Me.InventorDocument.Parent.CommandManager.UserInputEvents
171 |
172 | GetAttributes()
173 |
174 | ' Create the tree to show the attributes.
175 | Me.treeView.BeginUpdate()
176 | For Each entity As MyEntity In m_Entities
177 | m_ObjectList.Add(entity)
178 |
179 | m_NodeCount += 1
180 | Dim entityNode As TreeNode = Me.treeView.Nodes.Add(m_NodeCount.ToString, GoodEntityName(entity.Entity), 3)
181 | entityNode.ContextMenuStrip = ctxMenu
182 | entity.TreeNode = entityNode
183 | entityNode.ImageIndex = 3
184 | entityNode.SelectedImageIndex = 3
185 | entityNode.StateImageKey = 3
186 |
187 | For Each attribSet As MyAttributeSet In entity.AttributeSets
188 | m_ObjectList.Add(attribSet)
189 |
190 | m_NodeCount += 1
191 | Dim attribSetNode As TreeNode = entityNode.Nodes.Add(m_NodeCount.ToString, attribSet.Name, 0)
192 | attribSetNode.ContextMenuStrip = ctxMenu
193 | attribSet.TreeNode = attribSetNode
194 | attribSetNode.ImageIndex = 0
195 | attribSetNode.SelectedImageIndex = 0
196 | attribSetNode.StateImageIndex = 0
197 |
198 | For Each attrib As MyAttribute In attribSet
199 | m_ObjectList.Add(attrib)
200 |
201 | m_NodeCount += 1
202 | Dim attribNode As TreeNode = attribSetNode.Nodes.Add(m_NodeCount.ToString, attrib.Name & " = " & attrib.ValueAsString, 2)
203 | attribNode.ContextMenuStrip = ctxMenu
204 | attrib.TreeNode = attribNode
205 | attribNode.ImageIndex = 2
206 | attribNode.SelectedImageIndex = 2
207 | attribNode.StateImageIndex = 2
208 | Next
209 | Next
210 | Next
211 |
212 | Me.treeView.EndUpdate()
213 |
214 | '' Kick the tree so that everything is displayed.
215 | 'Me.treeView.ExpandAll()
216 | 'Me.treeView.CollapseAll()
217 | 'Me.treeView.Nodes.Item(0).EnsureVisible()
218 |
219 | m_HighlightSet = Me.InventorDocument.CreateHighlightSet
220 | End If
221 | Catch ex As Exception
222 | MsgBox("Unexepected failure while loading the form.")
223 | End Try
224 | End Sub
225 |
226 | Private Function GoodEntityName(ByVal Entity As Object) As String
227 | Dim tempName As String = TypeName(Entity)
228 | If tempName.Substring(0, 3).ToLower = "irx" Then
229 | Return tempName.Substring(3)
230 | Else
231 | Return tempName
232 | End If
233 | End Function
234 |
235 | Private Sub GetAttributes()
236 | Dim attribManager As Inventor.AttributeManager = Me.InventorDocument.AttributeManager
237 | Dim attributedEntities As Inventor.ObjectCollection = attribManager.FindObjects("*", "*")
238 |
239 | ' Reinitialize the data.
240 | m_Entities = New MyEntities
241 |
242 | g_IgnoreDuringLoad = True
243 |
244 | ' Iterate through the entities that have attributes.
245 | For Each invEntity As Object In attributedEntities
246 | Dim currentEntity As MyEntity = m_Entities.Add(invEntity)
247 |
248 | Dim attSets As Inventor.AttributeSets
249 | attSets = invEntity.AttributeSets
250 |
251 | For Each attSet As Inventor.AttributeSet In invEntity.AttributeSets
252 | Dim currentAttSet As MyAttributeSet = currentEntity.AttributeSets.Add(attSet.Name, attSet)
253 |
254 | For Each attrib As Inventor.Attribute In attSet
255 | currentAttSet.Add(attrib.Name, attrib.ValueType, attrib.Value)
256 | Next
257 | Next
258 | Next
259 |
260 | ' Get the attribute sets that aren't associated with any entity. This happens
261 | ' when the entity is deleted or consumed in some operation. The attribute
262 | ' set is not automatically cleaned up.
263 | Dim detachedAttribSets As Object = Nothing
264 | attribManager.PurgeAttributeSets("*", True, detachedAttribSets)
265 |
266 | If Not detachedAttribSets Is Nothing Then
267 | For Each attSet As Inventor.AttributeSet In detachedAttribSets
268 | Dim currentEntity As MyEntity = m_Entities.Add(Nothing)
269 |
270 | Dim currentAttSet As MyAttributeSet = currentEntity.AttributeSets.Add(attSet.Name, attSet)
271 | For Each attrib As Inventor.Attribute In attSet
272 | Call currentAttSet.Add(attrib.Name, attrib.Type, attrib.Value)
273 | Next
274 | Next
275 | End If
276 |
277 | g_IgnoreDuringLoad = False
278 | End Sub
279 |
280 | Private Sub treeView_AfterCollapse(ByVal sender As Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles treeView.AfterCollapse
281 | If Not e.Node.Parent Is Nothing Then
282 | e.Node.ImageIndex = 0
283 | e.Node.SelectedImageIndex = 0
284 | e.Node.StateImageIndex = 0
285 | End If
286 | End Sub
287 |
288 | Private Sub treeView_AfterExpand(ByVal sender As Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles treeView.AfterExpand
289 | If Not e.Node.Parent Is Nothing Then
290 | e.Node.ImageIndex = 1
291 | e.Node.SelectedImageIndex = 1
292 | e.Node.StateImageIndex = 1
293 | End If
294 | End Sub
295 |
296 | Private Sub treeView_AfterLabelEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.NodeLabelEditEventArgs) Handles treeView.AfterLabelEdit
297 | ' Check to make sure there aren't any spaces in the attribute set name.
298 | If e.Label.Trim.Contains(" ") Then
299 | MsgBox("An attribute set name cannot contain any spaces.")
300 | e.CancelEdit = True
301 | End If
302 |
303 | ' Get the entity from the edited tree node.
304 | Dim ent As MyEntity = m_Entities.Item(e.Node.Parent)
305 |
306 | ' Find the attribute set.
307 | If Not ent Is Nothing Then
308 | For Each attSet As MyAttributeSet In ent.AttributeSets
309 | If e.Node.Text = attSet.Name Then
310 | ' Reassign the name.
311 | attSet.Name = e.Label.Trim
312 | End If
313 | Next
314 | End If
315 | End Sub
316 |
317 | Private Sub treeView_AfterSelect(ByVal sender As Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles treeView.AfterSelect
318 | Try
319 | ' Clear the select set.
320 | Me.InventorDocument.SelectSet.Clear()
321 |
322 | ' Special case based on the type of node.
323 | Select Case e.Node.ImageIndex
324 | Case 3, 4 ' Entity node
325 | ' Get the selected entity.
326 | Dim entity As MyEntity = m_ObjectList.Item(CType(e.Node.Name, Integer))
327 | SelectEntityNode(entity)
328 | Case 0, 1 ' AttributeSet node
329 | Dim attribSet As MyAttributeSet = m_ObjectList.Item(CType(e.Node.Name, Integer))
330 | SelectEntityNode(attribSet.Parent.Parent)
331 | Case 2 ' Attribute
332 | Dim attrib As MyAttribute = m_ObjectList.Item(CType(e.Node.Name, Integer))
333 | SelectEntityNode(attrib.Parent.Parent.Parent)
334 | End Select
335 | Catch ex As Exception
336 | ' Do nothing. MsgBox("Unexepected failure highlighting the selected node.")
337 | End Try
338 | End Sub
339 |
340 | Private Sub SelectEntityNode(ByVal Entity As MyEntity)
341 | ' Clear the current highlight set.
342 | m_HighlightSet.Clear()
343 |
344 | ' Highlight the selected entity.
345 | If Not Entity.Entity Is Nothing Then
346 | m_HighlightSet.AddItem(Entity.Entity)
347 |
348 | ' Change all entity nodes to be an unselected arrow.
349 | Dim checkNode As TreeNode = Me.treeView.TopNode
350 | Do
351 | checkNode.ImageIndex = 3
352 | checkNode.SelectedImageIndex = 3
353 | checkNode.StateImageIndex = 3
354 | checkNode = checkNode.NextNode
355 | Loop While Not checkNode Is Nothing
356 |
357 | ' Change the selected node to be a selected arrow.
358 | Entity.TreeNode.ImageIndex = 4
359 | Entity.TreeNode.SelectedImageIndex = 4
360 | Entity.TreeNode.StateImageIndex = 4
361 | End If
362 | End Sub
363 |
364 | Private Sub treeView_NodeMouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.TreeNodeMouseClickEventArgs) Handles treeView.NodeMouseClick
365 | Try
366 | treeView.SelectedNode = e.Node
367 | m_LastMousePosition = e.Location
368 | m_LastMousePosition.X = m_LastMousePosition.X + Me.Left
369 | m_LastMousePosition.Y = m_LastMousePosition.Y + Me.Top
370 | Catch ex As Exception
371 | MsgBox("Unexepected failure while selecting the tree node.")
372 | End Try
373 | End Sub
374 |
375 | Private Sub treeView_NodeMouseDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.TreeNodeMouseClickEventArgs) Handles treeView.NodeMouseDoubleClick
376 | Try
377 | Select Case e.Node.ImageIndex
378 | Case 0, 1 ' AttributeSet node
379 | treeView.LabelEdit = True
380 | e.Node.BeginEdit()
381 | Case 2 ' Attribute
382 | treeView.SelectedNode = e.Node
383 | m_LastMousePosition = e.Location
384 | m_LastMousePosition.X = m_LastMousePosition.X + Me.Left
385 | m_LastMousePosition.Y = m_LastMousePosition.Y + Me.Top
386 |
387 | EditAttributeWithDialog()
388 | End Select
389 | Catch ex As Exception
390 | MsgBox("Unexepected failure while double-clicking the tree node.")
391 | End Try
392 | End Sub
393 |
394 | ' Disable the contextual mini toolbar. This is the toolbar that's displayed when you select an entity.
395 | ' It's disabled by clearing it's contents just before it's displayed.
396 | Private Sub m_InputEvents_OnContextualMiniToolbar(SelectedEntities As Inventor.ObjectsEnumerator, DisplayedCommands As Inventor.NameValueMap, AdditionalInfo As Inventor.NameValueMap) Handles m_InputEvents.OnContextualMiniToolbar
397 | DisplayedCommands.Clear()
398 | End Sub
399 |
400 | Private Sub m_InputEvents_OnActivateOrTerminateCommand(CommandName As String, Context As Inventor.NameValueMap) Handles m_InputEvents.OnActivateCommand, m_InputEvents.OnTerminateCommand
401 | ' Another command was started or one was terminated, so terminate this program.
402 | ' The reason this is being used instead of InteractionEvents is because I want
403 | ' to use the more general NW arrow selection which has a wider filter range
404 | ' and is controlled by the user using the selection options. One issue is
405 | ' that I don't get notified if the Escape key is pressed while in the NW arrow
406 | ' command so I can't terminate based on that.
407 | If Not (CommandName.Contains("ViewCmd") Or CommandName.Contains("WindowCmd")) Then
408 | m_HighlightSet.Clear()
409 |
410 | ' Check to see if changes have been made.
411 | If m_Entities.HasChanges Then
412 | ' See if they want the changes saved.
413 | If MsgBox("You are aborting the Attribute Helper command and have made changes to attribute data. Do you want to save the changes?", MsgBoxStyle.YesNo + MsgBoxStyle.Question, "Save Attribute Changes") = MsgBoxResult.Yes Then
414 | For Each entity As MyEntity In m_Entities
415 | UpdateEntity(entity)
416 | Next
417 | End If
418 | End If
419 |
420 | CleanUp()
421 | Me.Close()
422 | End If
423 | End Sub
424 |
425 |
426 | Private Sub ctxMenu_Opening(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles ctxMenu.Opening
427 | Try
428 | ' Determine context.
429 | Select Case treeView.SelectedNode.ImageIndex
430 | Case 3, 4 ' Entity node
431 | If treeView.SelectedNode.Text = "Nothing" Then
432 | ctxMenu.Items(0).Visible = False
433 | ctxMenu.Items(1).Visible = True
434 | ctxMenu.Items(2).Visible = False
435 | ctxMenu.Items(3).Visible = False
436 | ctxMenu.Items(4).Visible = False
437 | ctxMenu.Items(5).Visible = False
438 | ctxMenu.Items(6).Visible = False
439 | Else
440 | ctxMenu.Items(0).Visible = True
441 | ctxMenu.Items(1).Visible = True
442 | ctxMenu.Items(2).Visible = False
443 | ctxMenu.Items(3).Visible = False
444 | ctxMenu.Items(4).Visible = False
445 | ctxMenu.Items(5).Visible = False
446 | ctxMenu.Items(6).Visible = False
447 | End If
448 |
449 | e.Cancel = False
450 | Case 0, 1 ' AttributeSet node
451 | ctxMenu.Items(0).Visible = False
452 | ctxMenu.Items(1).Visible = False
453 | ctxMenu.Items(2).Visible = True
454 | ctxMenu.Items(3).Visible = True
455 | ctxMenu.Items(4).Visible = True
456 | ctxMenu.Items(5).Visible = False
457 | ctxMenu.Items(6).Visible = False
458 |
459 | e.Cancel = False
460 | Case 2 ' Attribute
461 | ctxMenu.Items(0).Visible = False
462 | ctxMenu.Items(1).Visible = False
463 | ctxMenu.Items(2).Visible = False
464 | ctxMenu.Items(3).Visible = False
465 | ctxMenu.Items(4).Visible = False
466 | ctxMenu.Items(5).Visible = True
467 | ctxMenu.Items(6).Visible = True
468 |
469 | e.Cancel = False
470 | End Select
471 | Catch ex As Exception
472 | MsgBox("Unexepected failure while displaying the treeview context menu.")
473 | End Try
474 | End Sub
475 |
476 | Private Function EditAttribute(ByVal AttributeName As String, ByVal AttributeValue As String, ByVal EditNode As TreeNode) As Boolean
477 | AttributeName = AttributeName.Trim
478 | If AttributeName.Contains(" ") Then
479 | MsgBox("Attribute names cannot contain any spaces.")
480 | Return False
481 | End If
482 |
483 | ' Get the associated Attribute object.
484 | Dim attrib As MyAttribute = m_ObjectList.Item(CType(EditNode.Name, Integer))
485 | Dim attribSet As MyAttributeSet = attrib.Parent
486 | Dim entity As MyEntity = attribSet.Parent.Parent
487 |
488 | ' Check to see if anything has changed and that the new values are valid.
489 | If attrib.Name <> AttributeName Then
490 | ' Check if any other attributes have this name.
491 | For Each checkAttrib As MyAttribute In attribSet
492 | If checkAttrib.Name = AttributeName Then
493 | MsgBox("The name of the attribute must be unique within this attribute set.")
494 | Return False
495 | End If
496 | Next
497 |
498 | attrib.Name = AttributeName
499 | End If
500 |
501 | If attrib.ValueAsFullString <> AttributeValue Then
502 | ' Check that the specified string is valid for the value type.
503 | Select Case attrib.AttributeType
504 | Case Inventor.ValueTypeEnum.kStringType
505 | attrib.Value = AttributeValue
506 | Case Inventor.ValueTypeEnum.kIntegerType
507 | Dim intValue As Integer
508 | Try
509 | intValue = CType(AttributeValue, Integer)
510 | Catch ex As Exception
511 | MsgBox("The value entered is not a valid Integer type. It must be in the range of -2147483647 to 2147483647.")
512 | Return False
513 | End Try
514 | attrib.Value = intValue
515 | Case Inventor.ValueTypeEnum.kDoubleType
516 | Dim dblValue As Double
517 | Try
518 | dblValue = CType(AttributeValue, Double)
519 | Catch ex As Exception
520 | MsgBox("The value entered is not a valid Double type.")
521 | Return False
522 | End Try
523 | attrib.Value = dblValue
524 | Case Inventor.ValueTypeEnum.kByteArrayType
525 | Dim values() As String = AttributeValue.Split(","c)
526 | Dim newArray() As Byte
527 | ReDim newArray(values.Length - 1)
528 | Dim i As Integer = 0
529 | For Each checkValue As String In values
530 | Dim bytValue As Byte
531 | Try
532 | bytValue = CType(checkValue, Byte)
533 | Catch ex As Exception
534 | MsgBox("The value """ & checkValue & """ is not a valid Byte value")
535 | Return False
536 | End Try
537 |
538 | newArray(i) = CType(checkValue, Byte)
539 | i += 1
540 | Next
541 |
542 | attrib.Value = newArray
543 | End Select
544 | End If
545 |
546 | EditNode.Text = attrib.Name & " = " & attrib.ValueAsString
547 |
548 | Return True
549 | End Function
550 |
551 | Private Function CreateAttribute(ByVal AttributeName As String, ByVal AttributeType As Inventor.ValueTypeEnum, ByVal AttributeValue As String, ByVal EditNode As TreeNode) As Boolean
552 | AttributeName = AttributeName.Trim
553 | If AttributeName.Contains(" ") Then
554 | MsgBox("Attribute names cannot contain any spaces.")
555 | Return False
556 | End If
557 |
558 | ' Get the associated Attribute set object.
559 | Dim attribSet As MyAttributeSet = m_ObjectList.Item(CType(Me.treeView.SelectedNode.Name, Integer))
560 | Dim entity As MyEntity = attribSet.Parent.Parent
561 |
562 | ' Check that the specified string is valid for the value type.
563 | Dim attrib As MyAttribute = Nothing
564 | Select Case AttributeType
565 | Case Inventor.ValueTypeEnum.kStringType
566 | attrib = attribSet.Add(AttributeName, Inventor.ValueTypeEnum.kStringType, AttributeValue)
567 | Case Inventor.ValueTypeEnum.kIntegerType
568 | Dim intValue As Integer
569 | Try
570 | intValue = CType(AttributeValue, Integer)
571 | Catch ex As Exception
572 | MsgBox("The value entered is not a valid Integer type. It must be in the range of -2147483647 to 2147483647.")
573 | Return False
574 | End Try
575 |
576 | attrib = attribSet.Add(AttributeName, Inventor.ValueTypeEnum.kIntegerType, intValue)
577 | Case Inventor.ValueTypeEnum.kDoubleType
578 | Dim dblValue As Double
579 | Try
580 | dblValue = CType(AttributeValue, Double)
581 | Catch ex As Exception
582 | MsgBox("The value entered is not a valid Double type.")
583 | Return False
584 | End Try
585 |
586 | attrib = attribSet.Add(AttributeName, Inventor.ValueTypeEnum.kDoubleType, dblValue)
587 | Case Inventor.ValueTypeEnum.kByteArrayType
588 | Dim values() As String = AttributeValue.Split(","c)
589 | Dim newArray() As Byte
590 | ReDim newArray(values.Length - 1)
591 | Dim i As Integer = 0
592 | For Each checkValue As String In values
593 | Dim bytValue As Byte
594 | Try
595 | bytValue = CType(checkValue, Byte)
596 | Catch ex As Exception
597 | MsgBox("The value """ & checkValue & """ is not a valid Byte value")
598 | Return False
599 | End Try
600 |
601 | newArray(i) = CType(checkValue, Byte)
602 | i += 1
603 | Next
604 |
605 | attrib = attribSet.Add(AttributeName, Inventor.ValueTypeEnum.kByteArrayType, newArray)
606 | If attrib Is Nothing Then
607 | Return False
608 | End If
609 | End Select
610 |
611 | ' Add a node to the tree.
612 | If Not attrib Is Nothing Then
613 | m_ObjectList.Add(attrib)
614 |
615 | m_NodeCount += 1
616 | Dim attribNode As TreeNode = attribSet.TreeNode.Nodes.Add(m_NodeCount.ToString, attrib.Name & " = " & attrib.ValueAsString, 2)
617 | attribNode.ImageIndex = 2
618 | attribNode.SelectedImageIndex = 2
619 | attribNode.StateImageIndex = 2
620 | attribNode.ContextMenuStrip = ctxMenu
621 | attribNode.EnsureVisible()
622 | End If
623 |
624 | Return True
625 | End Function
626 |
627 |
628 | Private Sub m_FindAttributeInDialogButtonDef_OnExecute(Context As Inventor.NameValueMap) Handles m_FindAttributeInDialogButtonDef.OnExecute
629 | ' Select the entity within the dialog.
630 | If Not m_SelectedEntity Is Nothing Then
631 | Dim ent As MyEntity = m_Entities.Item(m_SelectedEntity)
632 | If Not ent Is Nothing Then
633 | ent.SelectEntity()
634 | End If
635 | End If
636 | End Sub
637 |
638 |
639 | Private Sub m_AddAttributeSetButtonDef_OnExecute(Context As Inventor.NameValueMap) Handles m_AddAttributeSetButtonDef.OnExecute
640 | Try
641 | Dim attributeSetName As String = ""
642 | attributeSetName = InputBox("Enter the name of the attribute set.", "Create Attribute Set", , Me.Left + 25, Me.Top + 50)
643 |
644 | If attributeSetName <> "" Then
645 | If attributeSetName.Trim.Contains(" ") Then
646 | MsgBox("An attribute set name cannot contain any spaces.")
647 | Exit Sub
648 | Else
649 | attributeSetName = attributeSetName.Trim
650 | End If
651 |
652 | ' Check to see if this entity is already in the tree.
653 | Dim existingEntity As Boolean = False
654 | For Each ent As MyEntity In m_Entities
655 | If ent.Entity Is m_SelectedEntity Then
656 | ' Check to see that the name is unique.
657 | For Each testAttribSet As MyAttributeSet In ent.AttributeSets
658 | If testAttribSet.Name.ToLower = attributeSetName.ToLower Then
659 | MsgBox("The specified attribute set name is already used" & vbCr & "by an attribute set on the selected entity.", MsgBoxStyle.OkOnly + MsgBoxStyle.Exclamation)
660 | Exit Sub
661 | End If
662 | Next
663 |
664 | ' Add a new attribute set to this entity.
665 | Dim attribSet As MyAttributeSet = ent.AttributeSets.Add(attributeSetName)
666 | attribSet.IsNew = True
667 |
668 | ' Add a new node to the tree.
669 | m_ObjectList.Add(attribSet)
670 |
671 | m_NodeCount += 1
672 | Dim attribSetNode As TreeNode = ent.TreeNode.Nodes.Add(m_NodeCount.ToString, attributeSetName, 0)
673 | attribSetNode.ContextMenuStrip = ctxMenu
674 | attribSet.TreeNode = attribSetNode
675 | attribSetNode.ImageIndex = 0
676 | attribSetNode.SelectedImageIndex = 0
677 | attribSetNode.StateImageIndex = 0
678 |
679 | existingEntity = True
680 | Exit For
681 | End If
682 | Next
683 |
684 | If Not existingEntity Then
685 | ' Create a new entity.
686 | Dim newEntity As MyEntity = m_Entities.Add(m_SelectedEntity)
687 | newEntity.IsNew = True
688 |
689 | ' Add a new entity to the tree.
690 | m_ObjectList.Add(newEntity)
691 |
692 | m_NodeCount += 1
693 | Dim entityNode As TreeNode = Me.treeView.Nodes.Add(m_NodeCount.ToString, GoodEntityName(newEntity.Entity), 3)
694 | newEntity.TreeNode = entityNode
695 | entityNode.ContextMenuStrip = ctxMenu
696 | entityNode.ImageIndex = 3
697 | entityNode.SelectedImageIndex = 3
698 | entityNode.StateImageKey = 3
699 |
700 | ' Create a new attribute set.
701 | ' Add a new attribute set to this entity.
702 | Dim attribSet As MyAttributeSet = newEntity.AttributeSets.Add(attributeSetName)
703 | attribSet.IsNew = True
704 |
705 | ' Add the attribute set to the tree
706 | m_ObjectList.Add(attribSet)
707 |
708 | m_NodeCount += 1
709 | Dim attribSetNode As TreeNode = entityNode.Nodes.Add(m_NodeCount.ToString, attributeSetName, 0)
710 | attribSetNode.ContextMenuStrip = ctxMenu
711 | attribSet.TreeNode = attribSetNode
712 | attribSetNode.ImageIndex = 0
713 | attribSetNode.SelectedImageIndex = 0
714 | attribSetNode.StateImageIndex = 0
715 | End If
716 | End If
717 | Catch ex As Exception
718 | MsgBox("Unexpected failure while adding the attribute set.")
719 | End Try
720 | End Sub
721 |
722 | Private Sub AddAttributeSetToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles AddAttributeSetToolStripMenuItem.Click
723 | Try
724 | Dim attributeSetName As String = InputBox("Enter the name of the attribute set.", "Create Attribute Set", , Me.Left + 25, m_LastMousePosition.Y - 20)
725 | If attributeSetName <> "" Then
726 | If attributeSetName.Trim.Contains(" ") Then
727 | MsgBox("An attribute set name cannot contain any spaces.")
728 | Exit Sub
729 | End If
730 |
731 | Dim entity As MyEntity = m_ObjectList.Item(CType(treeView.SelectedNode.Name, Integer))
732 | Dim inventorEntity As Object = entity.Entity
733 |
734 | ' Check that this name is unique for that attribute sets on this entity.
735 | For Each testAttribSet As MyAttributeSet In entity.AttributeSets
736 | If testAttribSet.Name.ToLower = attributeSetName.ToLower Then
737 | MsgBox("The specified attribute set name is already used" & vbCr & "by an attribute set on the selected entity.", MsgBoxStyle.OkOnly + MsgBoxStyle.Exclamation)
738 | Exit Sub
739 | End If
740 | Next
741 |
742 | Try
743 | ' Add a new attribute set to this entity.
744 | Dim attribSet As MyAttributeSet = entity.AttributeSets.Add(attributeSetName)
745 | attribSet.IsNew = True
746 |
747 | ' Add a new node to the tree.
748 | m_ObjectList.Add(attribSet)
749 |
750 | m_NodeCount += 1
751 | Dim attribSetNode As TreeNode = entity.TreeNode.Nodes.Add(m_NodeCount.ToString, attributeSetName, 0)
752 | attribSetNode.ContextMenuStrip = ctxMenu
753 | attribSet.TreeNode = attribSetNode
754 | attribSetNode.ImageIndex = 0
755 | attribSetNode.SelectedImageIndex = 0
756 | attribSetNode.StateImageIndex = 0
757 | attribSetNode.EnsureVisible()
758 | Catch ex As Exception
759 | ' Do nothing
760 | End Try
761 | End If
762 | Catch ex As Exception
763 | MsgBox("Unexepected failure while adding the attribute set.")
764 | End Try
765 | End Sub
766 |
767 | Private Sub DeleteAllAttributesToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles DeleteAllAttributesToolStripMenuItem.Click
768 | Try
769 | Dim entity As MyEntity = m_ObjectList.Item(CType(treeView.SelectedNode.Name, Integer))
770 |
771 | For Each attribSet As MyAttributeSet In entity.AttributeSets
772 | attribSet.IsDeleted = True
773 | Next
774 |
775 | entity.TreeNode.Remove()
776 | entity.TreeNode = Nothing
777 | Catch ex As Exception
778 | MsgBox("Unexepected failure while deleting all attributes.")
779 | End Try
780 | End Sub
781 |
782 | Private Sub EditNameToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles EditNameToolStripMenuItem.Click
783 | Try
784 | treeView.LabelEdit = True
785 | treeView.SelectedNode.BeginEdit()
786 | Catch ex As Exception
787 | MsgBox("Unexepected failure while editing the attribute set name.")
788 | End Try
789 | End Sub
790 |
791 | Private Sub AddAttributeToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles AddAttributeToolStripMenuItem.Click
792 | Try
793 | ' Get the attribute set being the attribute is being added to.
794 | Dim attribSet As MyAttributeSet = m_ObjectList.Item(CType(treeView.SelectedNode.Name, Integer))
795 |
796 | ' Create the dialog.
797 | Dim editDialog As New EditAttribute
798 |
799 | ' Populate the dialog with the current information.
800 | editDialog.EditMode = False
801 |
802 | Dim badAttribute As Boolean = False
803 | Do
804 | editDialog.ShowDialog()
805 | If editDialog.DialogResult = Windows.Forms.DialogResult.OK Then
806 | If CreateAttribute(editDialog.AttributeName, editDialog.AttributeType, editDialog.AttributeValue, treeView.SelectedNode) Then
807 | badAttribute = False
808 | Else
809 | badAttribute = True
810 | End If
811 | Else
812 | badAttribute = False
813 | End If
814 | Loop While badAttribute
815 | Catch ex As Exception
816 | MsgBox("Unexepected failure while adding the attribute.")
817 | End Try
818 | End Sub
819 |
820 | Private Sub DeleteToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles DeleteAttributeSetToolStripMenuItem.Click, DeleteAttributeToolStripMenuItem.Click
821 | Try
822 | Dim selectedObject As Object = m_ObjectList(CType(treeView.SelectedNode.Name, Integer))
823 | selectedObject.IsDeleted = True
824 |
825 | treeView.SelectedNode.Remove()
826 | selectedObject.TreeNode = Nothing
827 | Catch ex As Exception
828 | MsgBox("Unexepected failure while deleting the attribute.")
829 | End Try
830 | End Sub
831 |
832 | Private Sub EditAttributeToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles EditAttributeToolStripMenuItem.Click
833 | EditAttributeWithDialog()
834 | End Sub
835 |
836 | Private Sub EditAttributeWithDialog()
837 | Try
838 | ' Get the attribute being edited.
839 | Dim attrib As MyAttribute = m_ObjectList.Item(CType(treeView.SelectedNode.Name, Integer))
840 |
841 | ' Create the dialog.
842 | Dim editDialog As New EditAttribute
843 |
844 | ' Populate the dialog with the current information.
845 | editDialog.AttributeName = attrib.Name
846 | editDialog.AttributeType = attrib.AttributeType
847 | editDialog.AttributeValue = attrib.ValueAsFullString
848 |
849 | editDialog.EditMode = True
850 | Dim badAttribute As Boolean = False
851 | Do
852 | editDialog.ShowDialog()
853 | If editDialog.DialogResult = Windows.Forms.DialogResult.OK Then
854 | If EditAttribute(editDialog.AttributeName, editDialog.AttributeValue, treeView.SelectedNode) Then
855 | badAttribute = False
856 | Else
857 | badAttribute = True
858 | End If
859 | Else
860 | badAttribute = False
861 | End If
862 | Loop While badAttribute
863 | Catch ex As Exception
864 | MsgBox("Unexepected failure while editing the attribute.")
865 | End Try
866 | End Sub
867 |
868 | Private Sub m_DocEvents_OnChangeSelectSet(ByVal BeforeOrAfter As Inventor.EventTimingEnum, ByVal Context As Inventor.NameValueMap, ByRef HandlingCode As Inventor.HandlingCodeEnum)
869 | If BeforeOrAfter = Inventor.EventTimingEnum.kAfter Then
870 | ' Clear any selection in the tree.
871 | If Not Me.treeView.TopNode Is Nothing Then
872 | Dim checkNode As TreeNode = Me.treeView.TopNode
873 | Do
874 | checkNode.ImageIndex = 3
875 | checkNode.SelectedImageIndex = 3
876 | checkNode.StateImageIndex = 3
877 | checkNode = checkNode.NextNode
878 | Loop While Not checkNode Is Nothing
879 |
880 | m_HighlightSet.Clear()
881 | End If
882 | End If
883 | End Sub
884 |
885 | Private Sub btnExpandAll_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExpandAll.Click
886 | treeView.ExpandAll()
887 | End Sub
888 |
889 | Private Sub btnCollapseAll_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCollapseAll.Click
890 | treeView.CollapseAll()
891 | End Sub
892 |
893 | Private Sub m_InputEvents_OnRadialMarkingMenu(SelectedEntities As Inventor.ObjectsEnumerator, SelectionDevice As Inventor.SelectionDeviceEnum, RadialMenu As Inventor.RadialMarkingMenu, AdditionalInfo As Inventor.NameValueMap) Handles m_InputEvents.OnRadialMarkingMenu
894 | RadialMenu.EastControl = Nothing
895 | RadialMenu.NorthControl = Nothing
896 | RadialMenu.NortheastControl = Nothing
897 | RadialMenu.NorthwestControl = Nothing
898 | RadialMenu.SouthControl = Nothing
899 | RadialMenu.SoutheastControl = Nothing
900 | RadialMenu.SouthwestControl = Nothing
901 | RadialMenu.WestControl = Nothing
902 | End Sub
903 |
904 | Private Sub m_InputEvents_OnLinearMarkingMenu(SelectedEntities As Inventor.ObjectsEnumerator, SelectionDevice As Inventor.SelectionDeviceEnum, LinearMenu As Inventor.CommandControls, AdditionalInfo As Inventor.NameValueMap) Handles m_InputEvents.OnLinearMarkingMenu
905 | Try
906 | ' Check to see if any of the objects in the select set support attributes.
907 | Dim entityFound As Boolean = False
908 | Try
909 | Dim attribSet As Inventor.AttributeSets = SelectedEntities.Item(1).AttributeSets
910 |
911 | ' If we got here then the entity does support attribute sets.
912 | m_SelectedEntity = Me.InventorDocument.SelectSet.Item(1)
913 | entityFound = True
914 | Catch ex As Exception
915 | m_SelectedEntity = Nothing
916 | End Try
917 |
918 | ' Remove all of the existing the controls in the list.
919 | For i As Integer = LinearMenu.Count To 1 Step -1
920 | LinearMenu.Item(i).Delete()
921 |
922 | 'Dim control As Inventor.CommandControl = LinearMenu.Item(i)
923 | 'If Not (control.InternalName.Contains("ViewCmd") Or control.InternalName.Contains("WindowCmd")) Then
924 | ' control.Delete()
925 | 'End If
926 | Next
927 |
928 | ' Add the appropriate command.
929 | If entityFound Then
930 | ' Check to see if the selected entity already has an attribute.
931 | If m_SelectedEntity.AttributeSets.Count = 0 Then
932 | ' Check to see if the entity has a pending attribute set added in the dialog.
933 | Dim testEnt As MyEntity = m_Entities.Item(m_SelectedEntity)
934 | If testEnt Is Nothing Then
935 | If LinearMenu.Count > 0 Then
936 | LinearMenu.AddButton(m_AddAttributeSetButtonDef, , , LinearMenu.Item(1).InternalName, True)
937 | Else
938 | LinearMenu.AddButton(m_AddAttributeSetButtonDef)
939 | End If
940 | Else
941 | If LinearMenu.Count > 0 Then
942 | LinearMenu.AddButton(m_AddAttributeSetButtonDef, , , LinearMenu.Item(1).InternalName, True)
943 | LinearMenu.AddButton(m_FindAttributeInDialogButtonDef, , , LinearMenu.Item(1).InternalName, True)
944 | Else
945 | LinearMenu.AddButton(m_AddAttributeSetButtonDef)
946 | LinearMenu.AddButton(m_FindAttributeInDialogButtonDef)
947 | End If
948 | End If
949 | Else
950 | If LinearMenu.Count > 0 Then
951 | LinearMenu.AddButton(m_AddAttributeSetButtonDef, , , LinearMenu.Item(1).InternalName, True)
952 | LinearMenu.AddButton(m_FindAttributeInDialogButtonDef, , , LinearMenu.Item(1).InternalName, True)
953 | Else
954 | LinearMenu.AddButton(m_AddAttributeSetButtonDef)
955 | LinearMenu.AddButton(m_FindAttributeInDialogButtonDef)
956 | End If
957 | End If
958 | End If
959 | Catch ex As Exception
960 | MsgBox("Unexepected failure while displaying the Inventor context menu.")
961 | End Try
962 | End Sub
963 |
964 | Private Sub btnHelp_Click(sender As Object, e As EventArgs) Handles btnHelp.Click
965 | Dim helpFile As String = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().CodeBase)
966 | If helpFile.StartsWith("file:\") Then
967 | helpFile = helpFile.Substring("file:\".Length)
968 | End If
969 | helpFile = helpFile & "\AttributeHelperReadMe.pdf"
970 |
971 | If System.IO.File.Exists(helpFile) Then
972 | Process.Start(helpFile)
973 | Else
974 | MsgBox("Problem locating help file.")
975 | End If
976 | End Sub
977 | End Class
978 |
979 |
980 | Friend Class MyEntities
981 | Inherits CollectionBase
982 |
983 | Public Function Add(ByVal Entity As Object) As MyEntity
984 | Try
985 | ' Create a new object
986 | Dim newMember As MyEntity
987 | newMember = New MyEntity
988 |
989 | ' Set the properties passed into the method
990 | newMember.Entity = Entity
991 |
992 | ' Add the object to the collection.
993 | MyBase.List.Add(newMember)
994 |
995 | ' Return the object created
996 | Add = newMember
997 | newMember = Nothing
998 | Catch ex As Exception
999 | ' Failure.
1000 | Return Nothing
1001 | End Try
1002 | End Function
1003 |
1004 | Public ReadOnly Property HasChanges() As Boolean
1005 | Get
1006 | For Each entity As MyEntity In Me
1007 | If entity.IsEdited Or entity.IsNew Then
1008 | Return True
1009 | Exit For
1010 | End If
1011 |
1012 | For Each attribSet As MyAttributeSet In entity.AttributeSets
1013 | If attribSet.IsDeleted Or attribSet.IsEdited Or attribSet.IsNew Then
1014 | Return True
1015 | Exit For
1016 | End If
1017 |
1018 | For Each attrib As MyAttribute In attribSet
1019 | If attrib.IsDeleted Or attrib.IsEdited Or attrib.IsNew Then
1020 | Return True
1021 | Exit For
1022 | End If
1023 | Next
1024 | Next
1025 | Next
1026 |
1027 | Return False
1028 | End Get
1029 | End Property
1030 |
1031 |
1032 | ' Returns the specified item of the collection.
1033 | '
1034 | ' indexKey - Index of the station to return. The first item in the collection has an index of 1.
1035 | Default Public ReadOnly Property Item(ByVal indexKey As Integer) As MyEntity
1036 | Get
1037 | Return CType(MyBase.List.Item(indexKey - 1), MyEntity)
1038 | End Get
1039 | End Property
1040 |
1041 |
1042 | ' InventorEntity - The Inventor entity to returns the corresponding MyEntity object for.
1043 | Default Public ReadOnly Property Item(ByVal InventorEntity As Object) As MyEntity
1044 | Get
1045 | For Each ent As MyEntity In Me
1046 | If ent.Entity Is InventorEntity Then
1047 | Return ent
1048 | End If
1049 | Next
1050 |
1051 | Return Nothing
1052 | End Get
1053 | End Property
1054 |
1055 | ' InventorEntity - The Inventor entity to returns the corresponding MyEntity object for.
1056 | Default Public ReadOnly Property Item(ByVal Node As TreeNode) As MyEntity
1057 | Get
1058 | For Each ent As MyEntity In Me
1059 | If ent.TreeNode Is Node Then
1060 | Return ent
1061 | End If
1062 | Next
1063 |
1064 | Return Nothing
1065 | End Get
1066 | End Property
1067 |
1068 | End Class
1069 |
1070 |
1071 | Friend Class MyEntity
1072 | Private m_Entity As Object
1073 | Private m_AttributeSets As MyAttributeSets
1074 | Private m_Node As TreeNode
1075 | Private m_New As Boolean
1076 |
1077 | Public Property IsNew() As Boolean
1078 | Get
1079 | Return m_New
1080 | End Get
1081 | Set(ByVal value As Boolean)
1082 | If Not g_IgnoreDuringLoad Then
1083 | m_New = value
1084 | End If
1085 | End Set
1086 | End Property
1087 |
1088 | Public ReadOnly Property IsEdited() As Boolean
1089 | Get
1090 | For Each attribSet As MyAttributeSet In AttributeSets
1091 | If attribSet.IsEdited Then
1092 | Return True
1093 | End If
1094 | Next
1095 |
1096 | Return False
1097 | End Get
1098 | End Property
1099 |
1100 | Public Property Entity() As Object
1101 | Get
1102 | Return m_Entity
1103 | End Get
1104 | Set(ByVal value As Object)
1105 | m_Entity = value
1106 | End Set
1107 | End Property
1108 |
1109 | Public ReadOnly Property AttributeSets() As MyAttributeSets
1110 | Get
1111 | Return m_AttributeSets
1112 | End Get
1113 | End Property
1114 |
1115 | Public Property TreeNode() As TreeNode
1116 | Get
1117 | Return m_Node
1118 | End Get
1119 | Set(ByVal value As TreeNode)
1120 | m_Node = value
1121 | End Set
1122 | End Property
1123 |
1124 | Public Sub SelectEntity()
1125 | If Not m_Node Is Nothing Then
1126 | m_Node.TreeView.SelectedNode = m_Node
1127 | m_Node.Expand()
1128 | End If
1129 | End Sub
1130 |
1131 | Public Sub New()
1132 | m_AttributeSets = New MyAttributeSets
1133 | m_AttributeSets.Parent = Me
1134 | m_Entity = Nothing
1135 | End Sub
1136 | End Class
1137 |
1138 |
1139 | Friend Class MyAttributeSets
1140 | Inherits CollectionBase
1141 | Private m_parent As MyEntity
1142 | Private m_isEdited As Boolean = False
1143 | Private m_New As Boolean
1144 |
1145 | Public Property IsNew() As Boolean
1146 | Get
1147 | Return m_New
1148 | End Get
1149 | Set(ByVal value As Boolean)
1150 | If Not g_IgnoreDuringLoad Then
1151 | m_New = value
1152 | End If
1153 | End Set
1154 | End Property
1155 |
1156 | Public Function Add(ByVal Name As String, Optional InventorAttributeSet As Inventor.AttributeSet = Nothing) As MyAttributeSet
1157 | Try
1158 | ' Create a new object
1159 | Dim newMember As MyAttributeSet
1160 | newMember = New MyAttributeSet
1161 | newMember.Parent = Me
1162 |
1163 | ' Set the properties passed into the method
1164 | newMember.Name = Name
1165 | newMember.InventorAttributeSet = InventorAttributeSet
1166 |
1167 | newMember.IsNew = True
1168 |
1169 | ' Add the object to the collection.
1170 | MyBase.List.Add(newMember)
1171 |
1172 | ' Return the object created
1173 | Add = newMember
1174 | newMember = Nothing
1175 | Catch ex As Exception
1176 | ' Failure.
1177 | Return Nothing
1178 | End Try
1179 | End Function
1180 |
1181 | Public ReadOnly Property IsEdited() As Boolean
1182 | Get
1183 | If m_isEdited Then
1184 | Return True
1185 | Else
1186 | For Each attribSet As MyAttribute In Me
1187 | If attribSet.IsEdited Then
1188 | Return True
1189 | End If
1190 | Next
1191 | End If
1192 |
1193 | Return False
1194 | End Get
1195 | End Property
1196 |
1197 | Public Property Parent() As MyEntity
1198 | Get
1199 | Return m_parent
1200 | End Get
1201 |
1202 | Set(ByVal value As MyEntity)
1203 | m_parent = value
1204 | End Set
1205 | End Property
1206 |
1207 |
1208 | Default Public ReadOnly Property Item(ByVal indexKey As Integer) As MyAttributeSet
1209 | Get
1210 | Return CType(MyBase.List.Item(indexKey - 1), MyAttributeSet)
1211 | End Get
1212 | End Property
1213 | End Class
1214 |
1215 |
1216 | Friend Class MyAttributeSet
1217 | Inherits CollectionBase
1218 |
1219 | Private m_originalName As String = ""
1220 | Private m_name As String = ""
1221 | Private m_Parent As MyAttributeSets
1222 | Private m_Node As TreeNode
1223 | Private m_isEdited As Boolean = False
1224 | Private m_Deleted As Boolean = False
1225 | Private m_New As Boolean = False
1226 | Private m_inventorAttributeSet As Inventor.AttributeSet = Nothing
1227 |
1228 | Public Property IsNew() As Boolean
1229 | Get
1230 | Return m_New
1231 | End Get
1232 | Set(ByVal value As Boolean)
1233 | If Not g_IgnoreDuringLoad Then
1234 | m_New = value
1235 | End If
1236 | End Set
1237 | End Property
1238 |
1239 | Public Property IsDeleted() As Boolean
1240 | Get
1241 | Return m_Deleted
1242 | End Get
1243 | Set(ByVal value As Boolean)
1244 | If Not g_IgnoreDuringLoad Then
1245 | m_Deleted = value
1246 | End If
1247 | End Set
1248 | End Property
1249 |
1250 | ' Adds a new attribute to the set.
1251 | Public Function Add(ByVal Name As String, ByVal AttribType As Inventor.ValueTypeEnum, ByVal Value As Object) As MyAttribute
1252 | Try
1253 | ' Create a new object
1254 | Dim newMember As MyAttribute
1255 | newMember = New MyAttribute
1256 |
1257 | ' Check that the name is unique.
1258 | For Each attrib As MyAttribute In Me
1259 | If attrib.Name.ToUpper = Name.ToUpper Then
1260 | MsgBox("The specified parameter name already exists.")
1261 | Return Nothing
1262 | End If
1263 | Next
1264 | ' Set the properties passed into the method
1265 |
1266 | newMember.Name = Name
1267 | newMember.AttributeType = AttribType
1268 | newMember.Value = Value
1269 | newMember.IsNew = True
1270 | newMember.Parent = Me
1271 |
1272 | ' Add the object to the collection.
1273 | MyBase.List.Add(newMember)
1274 |
1275 | ' Return the object created
1276 | Add = newMember
1277 | newMember = Nothing
1278 | Catch ex As Exception
1279 | ' Failure.
1280 | Return Nothing
1281 | End Try
1282 | End Function
1283 |
1284 | Public ReadOnly Property IsEdited() As Boolean
1285 | Get
1286 | If m_isEdited Then
1287 | Return True
1288 | Else
1289 | For Each attrib As MyAttribute In Me
1290 | If attrib.IsEdited Or attrib.IsNew Or attrib.IsDeleted Then
1291 | Return True
1292 | End If
1293 | Next
1294 | End If
1295 |
1296 | Return False
1297 | End Get
1298 | End Property
1299 |
1300 | Public Property Parent() As MyAttributeSets
1301 | Get
1302 | Return m_Parent
1303 | End Get
1304 | Set(ByVal value As MyAttributeSets)
1305 | m_Parent = value
1306 | End Set
1307 | End Property
1308 |
1309 | Public Property Name() As String
1310 | Get
1311 | Return m_name
1312 | End Get
1313 | Set(ByVal value As String)
1314 | If m_name = "" Then
1315 | m_originalName = value
1316 | End If
1317 |
1318 | m_name = value
1319 |
1320 | If Not g_IgnoreDuringLoad Then
1321 | m_isEdited = True
1322 | End If
1323 | End Set
1324 | End Property
1325 |
1326 | Public ReadOnly Property OriginalName As String
1327 | Get
1328 | Return m_originalName
1329 | End Get
1330 | End Property
1331 |
1332 | Default Public ReadOnly Property Item(ByVal indexKey As Integer) As MyAttribute
1333 | Get
1334 | Return CType(MyBase.List.Item(indexKey - 1), MyAttribute)
1335 | End Get
1336 | End Property
1337 |
1338 | Public Property TreeNode() As TreeNode
1339 | Get
1340 | Return m_Node
1341 | End Get
1342 | Set(ByVal value As TreeNode)
1343 | m_Node = value
1344 | End Set
1345 | End Property
1346 |
1347 | Public Property InventorAttributeSet() As Inventor.AttributeSet
1348 | Get
1349 | Return m_inventorAttributeSet
1350 | End Get
1351 | Set(value As Inventor.AttributeSet)
1352 | m_inventorAttributeSet = value
1353 | End Set
1354 | End Property
1355 | End Class
1356 |
1357 |
1358 | Friend Class MyAttribute
1359 | Private m_Name As String = ""
1360 | Private m_OriginalName As String
1361 | Private m_Type As Inventor.ValueTypeEnum
1362 | Private m_Value As Object
1363 | Private m_parent As MyAttributeSet
1364 | Private m_Node As TreeNode
1365 | Private m_IsEdited As Boolean = False
1366 | Private m_Deleted As Boolean = False
1367 | Private m_New As Boolean = False
1368 |
1369 | Public Property IsNew() As Boolean
1370 | Get
1371 | Return m_New
1372 | End Get
1373 | Set(ByVal value As Boolean)
1374 | If Not g_IgnoreDuringLoad Then
1375 | m_New = value
1376 | End If
1377 | End Set
1378 | End Property
1379 |
1380 | Public Property IsDeleted() As Boolean
1381 | Get
1382 | Return m_Deleted
1383 | End Get
1384 | Set(ByVal value As Boolean)
1385 | If Not g_IgnoreDuringLoad Then
1386 | m_Deleted = value
1387 | End If
1388 | End Set
1389 | End Property
1390 |
1391 | Public Property TreeNode() As TreeNode
1392 | Get
1393 | Return m_Node
1394 | End Get
1395 | Set(ByVal value As TreeNode)
1396 | m_Node = value
1397 | End Set
1398 | End Property
1399 |
1400 | Public Property Name() As String
1401 | Get
1402 | Return m_name
1403 | End Get
1404 | Set(ByVal value As String)
1405 | If m_name = "" Then
1406 | m_originalName = value
1407 | End If
1408 |
1409 | m_name = value
1410 |
1411 | If Not g_IgnoreDuringLoad Then
1412 | m_isEdited = True
1413 | End If
1414 | End Set
1415 | End Property
1416 |
1417 | Public ReadOnly Property OriginalName As String
1418 | Get
1419 | Return m_originalName
1420 | End Get
1421 | End Property
1422 |
1423 | Public Property AttributeType() As Inventor.ValueTypeEnum
1424 | Get
1425 | Return m_Type
1426 | End Get
1427 | Set(ByVal value As Inventor.ValueTypeEnum)
1428 | m_Type = value
1429 |
1430 | If Not g_IgnoreDuringLoad Then
1431 | m_IsEdited = True
1432 | End If
1433 | End Set
1434 | End Property
1435 |
1436 | Public Property Value() As Object
1437 | Get
1438 | Return m_Value
1439 | End Get
1440 | Set(ByVal value As Object)
1441 | m_Value = value
1442 |
1443 | If Not g_IgnoreDuringLoad Then
1444 | m_IsEdited = True
1445 | End If
1446 | End Set
1447 | End Property
1448 |
1449 | Public ReadOnly Property ValueAsString() As String
1450 | Get
1451 | If AttributeType = Inventor.ValueTypeEnum.kByteArrayType Then
1452 | Return "(Byte Array)"
1453 | Else
1454 | Return m_Value.ToString
1455 | End If
1456 | End Get
1457 | End Property
1458 |
1459 | Public ReadOnly Property ValueAsFullString() As String
1460 | Get
1461 | Dim arrayString As String = ""
1462 | If AttributeType = Inventor.ValueTypeEnum.kByteArrayType Then
1463 | For Each byteValue As Byte In m_Value
1464 | If arrayString = "" Then
1465 | arrayString = byteValue
1466 | Else
1467 | arrayString = arrayString & "," & byteValue
1468 | End If
1469 | Next
1470 | Return arrayString
1471 | Else
1472 | Return m_Value.ToString
1473 | End If
1474 | End Get
1475 | End Property
1476 |
1477 | Public ReadOnly Property IsEdited() As Boolean
1478 | Get
1479 | Return m_IsEdited
1480 | End Get
1481 | End Property
1482 |
1483 | Public Property Parent() As MyAttributeSet
1484 | Get
1485 | Return m_parent
1486 | End Get
1487 | Set(ByVal value As MyAttributeSet)
1488 | m_parent = value
1489 | End Set
1490 | End Property
1491 | End Class
1492 |
1493 |
1494 | Public Module Globals
1495 | Public g_IgnoreDuringLoad As Boolean = False
1496 | End Module
--------------------------------------------------------------------------------