dimension block name

dimension block name

Anonymous
Not applicable
392 Views
3 Replies
Message 1 of 4

dimension block name

Anonymous
Not applicable
in plain autolisp ... (cdr (assoc 2 (entget (car (entsel)))))
will give the dimension block name ex. "*D22"
these blocks are actually in the blocks collection object.

how can i get the block name, using VBA of a "AcadDimRotated" object.


thanx
mark
0 Likes
393 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable
Hi Mark,
In vba dimensions are treated as independant entities and blocks are
treated like a class that is instanced through out the drawing as an
entity called a blockreference. Dimensions are contained in the
modelspace (or paperspace) collection along with all the other entities.
The 2 are seperate and dimensions are not contained in the blocks
collection. What you may be looking for is the dimension's "objectid" or
"handle" property.
-Josh

Option Explicit
Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As
Integer

Sub GetDimInfo()
Dim Rot As AcadDimRotated
Dim ent As AcadEntity
Set ent = GetEnt
If TypeOf ent Is AcadDimRotated Then
Set Rot = ent
MsgBox Rot.ObjectID
MsgBox Rot.ObjectName
MsgBox Rot.Handle
End If
End Sub

Function GetEnt() As AcadEntity
Dim ent As AcadEntity
Dim Pt As Variant
Set ent = Nothing
On Error Resume Next
Do
ThisDrawing.Utility.getentity ent, Pt, "Pick an Object :"
If Err Then
If GetAsyncKeyState(&H1B) Then
Err.Clear
Exit Do
ElseIf ThisDrawing.GetVariable("errno") = "7" Or
ThisDrawing.GetVariable("errno") = "52" Then
Err.Clear
End If
End If
If Not ent Is Nothing Then
Set GetEnt = ent
Exit Do
End If
Loop
End Function


Mark wrote:

> in plain autolisp ... (cdr (assoc 2 (entget (car (entsel)))))
> will give the dimension block name ex. "*D22"
> these blocks are actually in the blocks collection object.
>
> how can i get the block name, using VBA of a "AcadDimRotated" object.
>
>
> thanx
> mark
>
>
>
0 Likes
Message 3 of 4

Anonymous
Not applicable
thanks Josh
actually i am looking for the lines/solids etc.
defining the dimension object, and i can get them
thru the blocks collection, but then which one
is which? (which blockref is which blockdef?)
mark


"Minkwitz Design" wrote in message
news:3C87A97A.1020403@ameritech.net...
> Hi Mark,
> In vba dimensions are treated as independant entities and blocks are
> treated like a class that is instanced through out the drawing as an
> entity called a blockreference. Dimensions are contained in the
> modelspace (or paperspace) collection along with all the other entities.
> The 2 are seperate and dimensions are not contained in the blocks
> collection. What you may be looking for is the dimension's "objectid" or
> "handle" property.
> -Josh
>
> Option Explicit
> Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As
> Integer
>
> Sub GetDimInfo()
> Dim Rot As AcadDimRotated
> Dim ent As AcadEntity
> Set ent = GetEnt
> If TypeOf ent Is AcadDimRotated Then
> Set Rot = ent
> MsgBox Rot.ObjectID
> MsgBox Rot.ObjectName
> MsgBox Rot.Handle
> End If
> End Sub
>
> Function GetEnt() As AcadEntity
> Dim ent As AcadEntity
> Dim Pt As Variant
> Set ent = Nothing
> On Error Resume Next
> Do
> ThisDrawing.Utility.getentity ent, Pt, "Pick an Object :"
> If Err Then
> If GetAsyncKeyState(&H1B) Then
> Err.Clear
> Exit Do
> ElseIf ThisDrawing.GetVariable("errno") = "7" Or
> ThisDrawing.GetVariable("errno") = "52" Then
> Err.Clear
> End If
> End If
> If Not ent Is Nothing Then
> Set GetEnt = ent
> Exit Do
> End If
> Loop
> End Function
>
>
> Mark wrote:
>
> > in plain autolisp ... (cdr (assoc 2 (entget (car (entsel)))))
> > will give the dimension block name ex. "*D22"
> > these blocks are actually in the blocks collection object.
> >
> > how can i get the block name, using VBA of a "AcadDimRotated" object.
> >
> >
> > thanx
> > mark
> >
> >
> >
>
0 Likes
Message 4 of 4

Anonymous
Not applicable
"Mark" wrote in message
news:35C4CFA209E8058083FC6B13625FF8A2@in.WebX.maYIadrTaRb...
> thanks Josh
> actually i am looking for the lines/solids etc.
> defining the dimension object, and i can get them
> thru the blocks collection, but then which one
> is which? (which blockref is which blockdef?)
> mark
>

Before this will work, you will need to register AxDb15.dll
which is located in the same folder as acad.exe, and you
must include a reference to the "ObjectDBX 1.0 Type Library"
in your project.

Public Function GetDimBlock(Dimension As AcadDimension) As AcadBlock
Dim dbxDoc As New AxDbDocument
Dim Doc As AcadDocument
Set Doc = Dimension.Document
Dim IdPairs As Variant
Dim IdPair As AcadIdPair
Dim ObjArray(0 To 0) As AcadObject
Set ObjArray(0) = Dimension
Doc.CopyObjects ObjArray, dbxDoc.ModelSpace, IdPairs
Dim i As Integer
For i = LBound(IdPairs) To UBound(IdPairs)
Set IdPair = IdPairs(i)
Dim Obj As AcadObject
Set Obj = Doc.ObjectIdToObject(IdPair.Key)
If TypeOf Obj Is AcadBlock Then
Set GetDimBlock = Obj
If Not GetDimBlock.IsLayout Then
Exit Function
End If
End If
Next i
End Function
0 Likes