I have been unable to find an example that leads me in the correct direction.
I was wondering if you could show me how to
Create a simple block with a line and a circle
Create three visibility states
1 with line visible only
1 with circle visible only
1 with both circle and line visible
It would also be nice if you could include an example of how to place a block on a drawing selecting one of the 3 visibility states
This is a "snippet" of working code that creates a simple block with attributes. I have not included all of the code, but you get the idea. This block that this code creates includes a lpolyline. I would like to add the capability to integrate visiblity states relative to this lpolyline.
I guess that my big question is. Is this possible using the .net API?
----------------------------------------------
oAcadTR = oAcadTM.StartTransaction
Dim oFlagBoxp1 As New Autodesk.autocad.geometry.Point2d(BoxSize / 2.0, BoxSize / 2.0)
Dim oFlagBoxp2 As New Autodesk.autocad.geometry.Point2d(BoxSize / 2.0, -BoxSize / 2.0)
Dim oFlagBoxp3 As New Autodesk.autocad.geometry.Point2d(-BoxSize / 2.0, -BoxSize / 2.0)
Dim oFlagBoxp4 As New Autodesk.autocad.geometry.Point2d(-BoxSize / 2.0, BoxSize / 2.0)
Dim oNoteIDPoint2d As New Autodesk.AutoCAD.Geometry.Point2d(0, 0.5)
Dim oNoteShortDescPoint2d As New Autodesk.AutoCAD.Geometry.Point2d(0, 1)
Dim oNoteCommentPoint2d As New Autodesk.AutoCAD.Geometry.Point2d(0, -0.5)
Dim oNoteIDPoint3d As New Autodesk.AutoCAD.Geometry.Point3d(0, 0.5, 0)
Dim oNoteShortDescPoint3d As New Autodesk.AutoCAD.Geometry.Point3d(0, 1, 0)
Dim oNoteCommentPoint3d As New Autodesk.AutoCAD.Geometry.Point3d(0, -0.5, 0)
Dim oNoteNoAttDef As New Autodesk.AutoCAD.DatabaseServices.AttributeDefinition(Autodesk.AutoCAD.Geometry.Point3d.Origin, "1", "NoteNumber", "Note Number", StyleID)
With oNoteNoAttDef
.Invisible = False
.HorizontalMode = TextHorizontalMode.TextMid
.VerticalMode = TextVerticalMode.TextVerticalMid
End With
Dim oShortDescAttDef As New Autodesk.AutoCAD.DatabaseServices.AttributeDefinition(oNoteShortDescPoint3d, "", "ShortDesc", "Short Description", StyleID)
With oShortDescAttDef
.Invisible = True
.HorizontalMode = TextHorizontalMode.TextLeft
.VerticalMode = TextVerticalMode.TextVerticalMid
.Position = oNoteShortDescPoint3d
.AlignmentPoint = oNoteShortDescPoint3d
End With
Dim oNoteIDAttDef As New Autodesk.AutoCAD.DatabaseServices.AttributeDefinition(oNoteIDPoint3d, "", "ID", "DatabaseID", StyleID)
With oNoteIDAttDef
.Invisible = True
.HorizontalMode = TextHorizontalMode.TextLeft
.VerticalMode = TextVerticalMode.TextVerticalMid
.Position = oNoteIDPoint3d
.AlignmentPoint = oNoteIDPoint3d
End With
Dim oCommentAttDef As New Autodesk.AutoCAD.DatabaseServices.AttributeDefinition(oNoteCommentPoint3d, "", "Comments", "Comments", StyleID)
With oCommentAttDef
.Invisible = True
.HorizontalMode = TextHorizontalMode.TextLeft
.VerticalMode = TextVerticalMode.TextVerticalMid
.Position = oNoteCommentPoint3d
.AlignmentPoint = oNoteCommentPoint3d
End With
Dim oFlagBox As New Autodesk.AutoCAD.DatabaseServices.Polyline(4)
With oFlagBox
.AddVertexAt(0, oFlagBoxp1, 0, -1, -1)
.AddVertexAt(1, oFlagBoxp2, 0, -1, -1)
.AddVertexAt(2, oFlagBoxp3, 0, -1, -1)
.AddVertexAt(3, oFlagBoxp4, 0, -1, -1)
.Closed = True
.Layer = LayerName
End With
Dim oNotesBlockTableRecord As BlockTableRecord = New BlockTableRecord
oNotesBlockTableRecord.Name = BlockName
oBlockTable = CType(oAcadTR.GetObject(oAcadDB.BlockTableId, OpenMode.ForWrite, False), BlockTable)
Dim oNotesBlockTableRecordID = oBlockTable.Add(oNotesBlockTableRecord)
oAcadTM.AddNewlyCreatedDBObject(oNotesBlockTableRecord, True)
oNotesBlockTableRecord.AppendEntity(oFlagBox)
oNotesBlockTableRecord.AppendEntity(oNoteNoAttDef)
oNotesBlockTableRecord.AppendEntity(oShortDescAttDef)
oNotesBlockTableRecord.AppendEntity(oNoteIDAttDef)
oNotesBlockTableRecord.AppendEntity(oCommentAttDef)
oAcadTR.AddNewlyCreatedDBObject(oFlagBox, True)
oAcadTR.AddNewlyCreatedDBObject(oNoteNoAttDef, True)
oAcadTR.AddNewlyCreatedDBObject(oShortDescAttDef, True)
oAcadTR.AddNewlyCreatedDBObject(oNoteIDAttDef, True)
oAcadTR.AddNewlyCreatedDBObject(oCommentAttDef, True)
oAcadTR.Commit()
oAcadTR.Dispose()
---------------------------------------