VB AttributeSet Attribute Creation - Help Needed


First, I just started VB earlier this week, so I am obviously deficient in that department. Second, I just pulled out what I believe to be the relevant code to get through this issue.


I am struggling to add custom attributes to a line which I have created. I can add AttributeSets without any problem, but I see no AttributeSet Items nor Atribute Items. My troubles seem to be with the last line of code as everything else seems to work just fine up until there.

My goal is to add information via VB as depicted in the two attached "Goal" images.


'Code Begin ---------------------------------------------------

Dim objApp As SolidEdgeFramework.Application = Marshal.GetActiveObject("SolidEdge.Application")
Dim objDoc As SolidEdgeDraft.DraftDocument = objApp.ActiveDocument

Dim objActiveSheet As SolidEdgeDraft.Sheet = objDoc.ActiveSheet
Dim objLines2d As SolidEdgeFrameworkSupport.Lines2d = objActiveSheet.Lines2d
Dim objLine2d As SolidEdgeFrameworkSupport.Line2d = Nothing
Dim strikeThrough_Horiz As SolidEdgeFrameworkSupport.Line2d = Nothing
Dim strikeThrough_Horiz_Name As String = Nothing
Dim objAttributeSets As SolidEdgeFramework.AttributeSets = Nothing
Dim objAttributeSet As SolidEdgeFramework.AttributeSet = Nothing
Dim objAttribute As SolidEdgeFramework.Attribute = Nothing

'Draws Horizontal Strike Through
strikeThrough_Horiz = objLines2d.AddBy2Points(0.255, 0.022, 0.315, 0.022)

'Change Width of Horizontal Strike Through
strikeThrough_Horiz.Style.Width = 0.002 '0.002 = 2.0 mm on draft sheet

objAttributeSets = strikeThrough_Horiz.AttributeSets
objAttributeSet = objAttributeSets.Add("TEST")  'Adds AttributeSets [1], but NOT Items (AttributeSet)

objAttribute = objAttributeSet.Add("Attribute Name", Name) 'Try to add Attribute, but fails with "Input string was not in a correct format."

'Code End ------------------------------------------------------

Thank you in advance!


Re: VB AttributeSet Attribute Creation - Help Needed

Solution Partner Phenom Solution Partner Phenom
Solution Partner Phenom

Hi matman,

AttributeSets can contain several Attribute lists. 

Only one (with the name "Default", see your Spy picture) is shown to the user. All others can be used by a program like yours. You named the list "TEST".

In this new AttributeSet you can add Attributes. The Add method has 2 parameters (Name and Type). 

The Type is from  AttributeTypeConstants enumeration.

There is a short example code in the documentation (AttributeSet Collection / Add Method)



VS2015, SE ST10

Re: VB AttributeSet Attribute Creation - Help Needed

Thank you so much for pointing me in the right direction. It worked!