Message 1 of 2
Attribute set doesn't stick to Title Block sketchline - 2010 VBA
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello, all. I am attempting modify my title block with VBA. I am using attributes to mark some specific sketch lines, but when I save the title block, the attributes disappear.
I manually edit the title block definition sketch, select a sketch line, and run:
Public Sub WriteAttribute()
Dim oDrawingDocument As Inventor.DrawingDocument
Set oDrawingDocument = ThisApplication.ActiveDocument
Dim oSketchLine As Inventor.SketchLine
Set oSketchLine = oDrawingDocument.SelectSet.Item(1)
Dim oLineAttributeSets As Inventor.AttributeSets
Set oLineAttributeSets = oSketchLine.AttributeSets
Dim oLineTestAttributeSet As Inventor.AttributeSet
Set oLineTestAttributeSet = oLineAttributeSets.Add("TestAttributeSet")
Dim oLineTestAttribute As Inventor.Attribute
Set oLineTestAttribute = oLineTestAttributeSet.Add("TestName", kStringType, "TestValue")
End Sub
After running the code, I can select the line and step through the first lines of code and set a watch for oDrawingDocument.SelectSet.Item(1).AttributeSets.Count, which shows 1. This means that I've successfully created an attribute set. But as soon as I save the title block (manually), the attributes disappear: If I again manually edit the title block, select the same line, and step through the first lines of code, a watch for oDrawingDocument.SelectSet.Item(1).AttributeSets.Count shows 0. Where is my attribute set and attribute going? Am I doing something wrong, or is it impossible to get the attributes to stick?
I manually edit the title block definition sketch, select a sketch line, and run:
Public Sub WriteAttribute()
Dim oDrawingDocument As Inventor.DrawingDocument
Set oDrawingDocument = ThisApplication.ActiveDocument
Dim oSketchLine As Inventor.SketchLine
Set oSketchLine = oDrawingDocument.SelectSet.Item(1)
Dim oLineAttributeSets As Inventor.AttributeSets
Set oLineAttributeSets = oSketchLine.AttributeSets
Dim oLineTestAttributeSet As Inventor.AttributeSet
Set oLineTestAttributeSet = oLineAttributeSets.Add("TestAttributeSet")
Dim oLineTestAttribute As Inventor.Attribute
Set oLineTestAttribute = oLineTestAttributeSet.Add("TestName", kStringType, "TestValue")
End Sub
After running the code, I can select the line and step through the first lines of code and set a watch for oDrawingDocument.SelectSet.Item(1).AttributeSets.Count, which shows 1. This means that I've successfully created an attribute set. But as soon as I save the title block (manually), the attributes disappear: If I again manually edit the title block, select the same line, and step through the first lines of code, a watch for oDrawingDocument.SelectSet.Item(1).AttributeSets.Count shows 0. Where is my attribute set and attribute going? Am I doing something wrong, or is it impossible to get the attributes to stick?