Dimension Styles using VB6

Dimension Styles using VB6

Anonymous
Not applicable
350 Views
2 Replies
Message 1 of 3

Dimension Styles using VB6

Anonymous
Not applicable
Is there a way to create my own Dimension Style with Visual Basic 6?
I want to create a new one, with my own configuration for linetype, color,
layer... and, if possible, with different settings for "Diameter",
"Ordinate" and "Radial" dimensions

Thanks in advance
0 Likes
351 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
The key to adding / creating "named dimstyles" is the "CopyFrom" method. The
sample below is for VBA but you can change the "Thisdrawing" object to your
VB6 document object to try it.

The Acad dimension variables are set up as desired in the active document
and then "copied from" the document to a named dimstyle.

HTH,

Gary

Dim CurDimStyle As AcadDimStyle
Dim NewDimstyle As AcadDimStyle
Dim iAltUnits As Integer
Dim dDimScale As Double

'Save copy of current dimstyle
Set CurDimStyle = ThisDrawing.ActiveDimStyle

'Create new dimstyle
Set NewDimstyle = ThisDrawing.DimStyles.Add("New_Dimstyle")

'Set newly created dimstyle current
ThisDrawing.ActiveDimStyle = NewDimstyle

'Save the target "dimvar" values
dDimScale = ThisDrawing.GetVariable("Dimscale")
iAltUnits = ThisDrawing.GetVariable("Dimalt")

'Alter the target "dimvar" values
ThisDrawing.SetVariable "Dimscale", 2#
ThisDrawing.SetVariable "Dimalt", 1

'Copy new document dimvar settings into new dimstyle
NewDimstyle.CopyFrom ThisDrawing

'Set original dimstyle current
ThisDrawing.ActiveDimStyle = CurDimStyle

'Restore the altered "dimvar" values
ThisDrawing.SetVariable "Dimscale", dDimScale
ThisDrawing.SetVariable "Dimalt", iAltUnits

'Copy restored document dimvar settings into original dimstyle
CurDimStyle.CopyFrom ThisDrawing

Set CurDimStyle = Nothing
Set NewDimstyle = Nothing
0 Likes
Message 3 of 3

Anonymous
Not applicable
Thank you Gary,

but with CopyFrom I can´t create styles for Diameter, Ordinate and
Radial, like Dimension Style Manager > New > User For: "Ordinate".



"Gary McMaster" escreveu na mensagem
news:5497603@discussion.autodesk.com...
The key to adding / creating "named dimstyles" is the "CopyFrom" method. The
sample below is for VBA but you can change the "Thisdrawing" object to your
VB6 document object to try it.

The Acad dimension variables are set up as desired in the active document
and then "copied from" the document to a named dimstyle.

HTH,

Gary

Dim CurDimStyle As AcadDimStyle
Dim NewDimstyle As AcadDimStyle
Dim iAltUnits As Integer
Dim dDimScale As Double

'Save copy of current dimstyle
Set CurDimStyle = ThisDrawing.ActiveDimStyle

'Create new dimstyle
Set NewDimstyle = ThisDrawing.DimStyles.Add("New_Dimstyle")

'Set newly created dimstyle current
ThisDrawing.ActiveDimStyle = NewDimstyle

'Save the target "dimvar" values
dDimScale = ThisDrawing.GetVariable("Dimscale")
iAltUnits = ThisDrawing.GetVariable("Dimalt")

'Alter the target "dimvar" values
ThisDrawing.SetVariable "Dimscale", 2#
ThisDrawing.SetVariable "Dimalt", 1

'Copy new document dimvar settings into new dimstyle
NewDimstyle.CopyFrom ThisDrawing

'Set original dimstyle current
ThisDrawing.ActiveDimStyle = CurDimStyle

'Restore the altered "dimvar" values
ThisDrawing.SetVariable "Dimscale", dDimScale
ThisDrawing.SetVariable "Dimalt", iAltUnits

'Copy restored document dimvar settings into original dimstyle
CurDimStyle.CopyFrom ThisDrawing

Set CurDimStyle = Nothing
Set NewDimstyle = Nothing
0 Likes