.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MTextAttributeDefinition Width Property not setting

0 REPLIES 0
Reply
Message 1 of 1
scottocad
501 Views, 0 Replies

MTextAttributeDefinition Width Property not setting

I am trying to set the width property of an mtext attribute definition and it is not setting it. No matter what value I set it to it always returns 0.0. Are there other properties or methods that need to be set or run before I can set this property?

I have tried to set the MTextAttributeDefinition to a new MText object and then set the poperties, but AutoCAD Crashes. Also I have tried to clone an existing Mtext object and then set the MTextAttributeDefinition to the clone, but AutoCad crashes.

Private Function CreateAttribute(ByVal tlca As InfoBlockAttribute, ByVal objData As AttributeData) As ObjectId
Dim rVal As ObjectId
Dim value As String

If tlca.UseFieldValue Then
value = tlca.FieldValue

Else
value = tlca.Value

End If

Using trans As Transaction = Drawing.WorkingDatabase.TransactionManager.StartTransaction
Dim space As BlockTableRecord = trans.GetObject(Drawing.WorkingDatabase.CurrentSpaceId, OpenMode.ForWrite)
Dim attDef As New AttributeDefinition(objData.InsertionPoint, value, tlca.Tag, tlca.Prompt, objData.Style)

With attDef
.Layer = objData.Layer
.Height = objData.Height
.Rotation = objData.Rotation
.Justify = objData.Justify
.WidthFactor = objData.WidthFactor
.Oblique = 0.0#
.Visible = True
.AlignmentPoint = New Point3d(objData.AlignmentPoint)

End With

'Object Id is a vaild MText objectId
If Not objData.ObjectId.IsNull Then
Dim mtext As MText = trans.GetObject(objData.ObjectId, OpenMode.ForRead)

attDef.IsMTextAttributeDefinition = True
attDef.UpdateMTextAttributeDefinition()

With attDef.MTextAttributeDefinition
.Attachment = mtext.Attachment
.Location = mtext.Location
.Direction = mtext.Direction
.FlowDirection = mtext.FlowDirection
.Width = mtext.Width
.LineSpacingFactor = mtext.LineSpacingFactor
.LineSpacingStyle = mtext.LineSpacingStyle
.Linetype = mtext.Linetype
.LinetypeScale = mtext.LinetypeScale
.LineWeight = mtext.LineWeight
.Rotation = mtext.Rotation
.TextHeight = mtext.TextHeight
.TextStyle = mtext.TextStyle
.UseBackgroundColor = mtext.UseBackgroundColor

End With

attDef.UpdateMTextAttributeDefinition()

End If

rVal = space.AppendEntity(attDef)

trans.AddNewlyCreatedDBObject(attDef, True)

trans.Commit()

End Using

Return rVal
End Function

Thanks for your help..
0 REPLIES 0

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost