Class Question - 'Function to Get 4 Attributes and Concantenate

Class Question - 'Function to Get 4 Attributes and Concantenate

Anonymous
Not applicable
497 Views
2 Replies
Message 1 of 3

Class Question - 'Function to Get 4 Attributes and Concantenate

Anonymous
Not applicable

Hello all, 

 

I'm scratching my head here... some hints please? 

 

I'm trying to create a property in a class "extractTitleBlock"

which searches through the "ExtractBlockRef (AttRef List)"

How would I search through a list of the class object above it? 

Or would there be a better best practice here? 

 

I'm using Jerry Winters "All things Extraction: From AutoCAD to Databases, Excel, and XML using .NET"

as my reference here. 

 

Follow? 

 

 

Public Class extractTitleBlock
	Inherits extractBlockRef

	Public ReadOnly Property Description_Concantenated() As String
		Get
			'Function to Get 4 Attributes and Return Concantenated String
		End Get
	End Property

end Class

Public Class extractBlockRef
	Inherits extractEntity
	Public Name As String
	Public Space As String
	Public Layout As String
	Public IsNested As Boolean
	Public Position As Point3d
	Public ScaleFactors As Scale3d
	Public Rotation As Double
	Public IsTitleBlock As Boolean
	Public Attributes As New List(Of extractAttRef)
	Public DynamicProps As New List(Of extractDynProp)
End Class

Public Class extractAttRef
	Inherits extractEntity
	Public Tag As String
	Public Value As String
	Sub New()
	End Sub
	Sub New(ByVal AttHandle As String, ByVal AttTag As String, ByVal AttValue As String)
		Handle = AttHandle
		Tag = AttTag
		Value = AttValue
	End Sub
End Class

Public Class extractEntity
	Private pHandle As String
	Private pLayer As String
	Property Handle() As String
		Get
			Return pHandle
		End Get
		Set(ByVal value As String)
			pHandle = value
		End Set
	End Property
	Property Layer() As String
		Get
			Return pLayer
		End Get
		Set(ByVal value As String)
			pLayer = value
		End Set
	End Property
End Class

 

'Find Attribute Functions
	Public Function FindTitleLine1Attribute(ByVal myAttribute As extractAttRef) As Boolean
		If myAttribute.Tag.ToUpper = "TILINE_1" Then 
			Return True
		Else
			Return False
		End If
	End Function

 

0 Likes
Accepted solutions (1)
498 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable

I guess what I'm really asking for is this? 

 

How would I search for a particular block that could be one of many TitleBlock Names.

I have my title block names in a database. 

 

Any ideas here? 

0 Likes
Message 3 of 3

norman.yuan
Mentor
Mentor
Accepted solution

You would go with these steps:

 

1. Retrieve all possibly used title block names from the database.

2. Loop through the title block name list to find a BlockTablerecord in BlockTable. You can use BlockTable. You can use BlockTable.Has([blockName]) to find out if a title block's definition exists in current drawing database or not.

3. If a BlockTableRecord is found, then you can use BlockTableRecord.GetBlockReferenceIds() to find all BlockReferences to ths blocktablerecord.

4. Then you can update the attributes in the found BlockReferences (title blocks) with data of your choice (from DB, worksheet, data file....)

5. If the BlockTableRecord is a dynamic block, make sure you also use BlockTableRecord.GetAnonymousBlockIds() to find all possible associated anonymous block definition and its BlockReferences.

Norman Yuan

Drive CAD With Code

EESignature