.NET

.NET

Reply
Valued Contributor
smcclure
Posts: 60
Registered: ‎06-08-2006
Message 1 of 3 (139 Views)

Copying the ScaleFactor to an AttributeReference

139 Views, 2 Replies
08-14-2006 08:26 AM
I am changing the ScaleFactor member of a BlockReference upon creating the block, although I found that (logically) the scale does not get applied to all AttributeReferences. I figured I would also apply the scale to each attribute while I was creating them. This proved to be difficult, though, since there is no ScaleFactor member for an AttributeReference. I started to try to apply the scale myself, but my attempts are failing.

My question is how should I apply the ScaleFactor from the block to the AttributeReference?

Currently, I use something like this (it doesnt work....)
attref.Position.ScaleBy(scale,new Point3d(0,0,0))
attref.Height *= scale
attref.WidthFactor *= scale
*Tony Tanzillo
Message 2 of 3 (139 Views)

Re: Copying the ScaleFactor to an AttributeReference

08-14-2006 05:28 PM in reply to: smcclure
If you create the attribute with the exact same
position, scale, rotation and extrusion direction
as its corresponding attribute definiton, then the
only thing you shoud have to do to put it where
it should be, is to call TransformBy on the attribute,
and pass in the transformation matrix returned
by the Block reference's BlockTransform property.


--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006/2007
http://www.acadxtabs.com

wrote in message news:5267679@discussion.autodesk.com...
I am changing the ScaleFactor member of a BlockReference upon creating the block, although I found that (logically) the scale does not get applied to all AttributeReferences. I figured I would also apply the scale to each attribute while I was creating them. This proved to be difficult, though, since there is no ScaleFactor member for an AttributeReference. I started to try to apply the scale myself, but my attempts are failing.

My question is how should I apply the ScaleFactor from the block to the AttributeReference?

Currently, I use something like this (it doesnt work....)
attref.Position.ScaleBy(scale,new Point3d(0,0,0))
attref.Height *= scale
attref.WidthFactor *= scale
Valued Contributor
smcclure
Posts: 60
Registered: ‎06-08-2006
Message 3 of 3 (139 Views)

Re: Copying the ScaleFactor to an AttributeReference

08-15-2006 06:41 AM in reply to: smcclure
I tried to copy the attribute using your suggestions below, and the attribute is not visible on the page. The comments that say "NEW" were code added to incorporate your suggestions. The code in comments worked, but did not copy over the scale.

Any suggestions would be greatly appreciated.

Thanks Tony for the help so far!

- Scott

[code]
Public Shared Sub CopyAttribute(ByRef def As AttributeDefinition, ByRef ref As AttributeReference, ByRef bref As BlockReference)
With ref
.HorizontalMode = def.HorizontalMode
.VerticalMode = def.VerticalMode
If def.VerticalMode <> TextVerticalMode.TextBase Or def.HorizontalMode <> TextHorizontalMode.TextLeft Then
'.AlignmentPoint = New Point3d(def.AlignmentPoint.X + bref.Position.X, _
' def.AlignmentPoint.Y + bref.Position.Y, _
' def.AlignmentPoint.Z + bref.Position.Z)
.AlignmentPoint = def.AlignmentPoint 'NEW
End If
.WidthFactor = def.WidthFactor
.FieldLength = def.FieldLength
.Height = def.Height
.Rotation = def.Rotation
.TextStyle = def.TextStyle
.Position = def.Position 'NEW
'.Position = New Point3d(def.Position.X + bref.Position.X, _
' def.Position.Y + bref.Position.Y, _
' def.Position.Z + bref.Position.Z)
.TransformBy(bref.BlockTransform) 'NEW
.Tag = def.Tag
.Layer = def.Layer
.Color = def.Color
.Linetype = def.Linetype
.TextString = def.TextString
End With
End Sub
[/code]
Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.