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

Copying the ScaleFactor to an AttributeReference

2 REPLIES 2
Reply
Message 1 of 3
smcclure
309 Views, 2 Replies

Copying the ScaleFactor to an AttributeReference

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
2 REPLIES 2
Message 2 of 3
Anonymous
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
Message 3 of 3
smcclure
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]

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