How to show dimensions of objects

How to show dimensions of objects

m09366023695
Enthusiast Enthusiast
542 Views
2 Replies
Message 1 of 3

How to show dimensions of objects

m09366023695
Enthusiast
Enthusiast

I have multi shapes.
I want to show all dimensions of each sides(the green lines).
BEYJd

 


I want to use `vba`.

I can show dimension a full square or rectangle shape.

for example to show a horizontal dimension I use this function:

 

 

Function createDimensionHorizental(x1, y1, x2, y2)

' This example creates an aligned dimension in model space and
' uses the TextHeight property to increase the height of the
' dimension text

Dim dimObj As AcadDimAligned
Dim point1(0 To 2) As Double, point2(0 To 2) As Double
Dim location(0 To 2) As Double

' Define the dimension
point1(0) = x1: point1(1) = y1: point1(2) = 0
point2(0) = x2: point2(1) = y1: point2(2) = 0
location(0) = x1: location(1) = y1 + 10: location(2) = 0

' Create an aligned dimension object in model space
Set dimObj = ThisDrawing.ModelSpace.AddDimAligned(point1, point2, location)


' Read and display current dimension text height
'MsgBox "The dimension text height for this object is currently set to: " & dimObj.TextHeight

' Increase the distance of the dimension gap
'Format the dimension object according to your needs.
With dimObj
.TextHeight = 30
.TextGap = 10 'The distance of the dimension text from the dimension line.
.Arrowhead1Type = 5 'acArrowOblique in early binding
.Arrowhead2Type = 5 'For the standard dimension arrow put 0 here.
.ArrowheadSize = 20
.ExtensionLineExtend = 10 'The amount to extend the extension line beyond the dimension line.
End With
ThisDrawing.Regen acAllViewports

End Function

 

 

0 Likes
543 Views
2 Replies
Replies (2)
Message 2 of 3

Ray-Sync
Advocate
Advocate

Hi. me=userform1 ..... me.hide and me.show. This is my answer. 

Private Sub CommandButton1_Click()
Dim Ent As AcadEntity
Dim pol(20) As AcadLWPolyline
Dim l(21) As AcadLine
Dim m As Variant, pt As Variant
Dim p(0 To 2) As Double
Dim r(21) As AcadDimAligned

Me.Hide

Call ThisDrawing.Utility.GetEntity(Ent, pt, "select line")

Set pol(0) = Ent
Set pol(1) = pol(0).Copy
m = pol(1).Explode

For i = 0 To 20
On Error Resume Next
Set l(i) = m(i)

p(0) = l(i).EndPoint(0): p(1) = l(i).EndPoint(1) + 1

Set r(i) = ThisDrawing.ModelSpace.AddDimAligned(l(i).StartPoint, l(i).EndPoint, p)
With r(i)
.HorizontalTextPosition = acHorzCentered
.VerticalTextPosition = acAbove
.TextHeight = 500
.PrimaryUnitsPrecision = acDimPrecisionTwo
End With

Next i

pol(1).Delete

For i = 0 To 20
On Error Resume Next
l(i).Delete
Next i

ThisDrawing.Regen True

Me.show
End Sub
jefferson
0 Likes
Message 3 of 3

Ed__Jobe
Mentor
Mentor

Have you tried the QDIM command?

 

You can write a program, but you need to define the rules for the program to follow. Maybe the rules that the QDIM command uses are good enough? You haven’t said much about which sides to include or exclude. 

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes