acadblock.insertionpoint?

acadblock.insertionpoint?

Anonymous
Not applicable
224 Views
4 Replies
Message 1 of 5

acadblock.insertionpoint?

Anonymous
Not applicable
Hi Guys,
How can I return the insertion point of a block in modelspace. There
may be ten instances of the block. When I select one, I want to retrieve
the insertion point for that instance. I can access the blockref
insertionpoint, but not the block insertionpoint. Any ideas?
-Josh
0 Likes
225 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable
Have you checked the Origin property?

--
Visit me at http://www2.stonemedia.com/franko

"Minkwitz Design" wrote in message
news:391B1B04.D4C0214D@xta.com...
> Hi Guys,
> How can I return the insertion point of a block in modelspace. There
> may be ten instances of the block. When I select one, I want to retrieve
> the insertion point for that instance. I can access the blockref
> insertionpoint, but not the block insertionpoint. Any ideas?
> -Josh
>
0 Likes
Message 3 of 5

Anonymous
Not applicable
Thanks for being so subtle Frank....No, I guess I didn't check the origin
property 🙂
-Josh

Frank Oquendo wrote:

> Have you checked the Origin property?
>
> --
> Visit me at http://www2.stonemedia.com/franko
>
> "Minkwitz Design" wrote in message
> news:391B1B04.D4C0214D@xta.com...
> > Hi Guys,
> > How can I return the insertion point of a block in modelspace. There
> > may be ten instances of the block. When I select one, I want to retrieve
> > the insertion point for that instance. I can access the blockref
> > insertionpoint, but not the block insertionpoint. Any ideas?
> > -Josh
> >
0 Likes
Message 4 of 5

Anonymous
Not applicable
Don't bother. It keeps returning 0,0,0.

--
Visit me at http://www2.stonemedia.com/franko

"Minkwitz Design" wrote in message
news:391B1DF9.8E44122A@xta.com...
> Thanks for being so subtle Frank....No, I guess I didn't check the origin
> property 🙂
> -Josh
0 Likes
Message 5 of 5

Anonymous
Not applicable
I figured it out anyway Frank, I place the block in a selectionset and then
scan the set for a blockreference. Blockreference.insertionpoint returns the
insertion point of the specified block. I didn't try it originally because I
assumed it was wrong. I had it backwards. The origin property returns the the
insertion point of the original. i.e.- a wblock created at 0,0,0.
-Josh
p.s.- throw this code in a standard module, place a couple of circles or insert
a couple of tapped holes ect. on the screen and run the macro.

Private Function LayerExists(LayerName As String) As Boolean 'LayerName as
String is Caps Sensitive
Dim Layr As AcadLayer
For Each Layr In ThisDrawing.Layers
If Layr.Name = LayerName Then LayerExists = True
Next
End Function

Public Sub Ordinate()
Dim SS1 As AcadSelectionSet
Dim Ent As AcadEntity
Dim Layr As AcadLayer
Dim BlkRef As AcadBlockReference
Dim Circ As AcadCircle
Dim ActivLayr As AcadLayer
Dim DimLayr As AcadLayer
Dim Xdim As AcadDimOrdinate
Dim Ydim As AcadDimOrdinate
Dim DefXpt(0 To 2) As Double
Dim DefYpt(0 To 2) As Double

Dim oPoint As Variant
Dim UCSzero(0 To 2) As Double
UCSzero(0) = 0: UCSzero(1) = 0: UCSzero(2) = 0
Set ActivLayr = ThisDrawing.ActiveLayer 'change to dim layer and remember
original layer
If LayerExists("DIM") = True Then
For Each Layr In ThisDrawing.Layers
If Layr.Name = "DIM" Then
Set DimLayr = Layr
End If
Next Layr
ThisDrawing.ActiveLayer = DimLayr
Else
Set DimLayr = ThisDrawing.Layers.Add("DIM")
DimLayr.Color = 11
ThisDrawing.ActiveLayer = DimLayr
End If

Set SS1 = ThisDrawing.SelectionSets.Add("DimSet") 'select stuff to dim
SS1.SelectOnScreen

Dim PrevSnapSetting As Integer ' remember old snaps
Const Intersection As Integer = 32
PrevSnapSetting = ThisDrawing.GetVariable("OSMODE")

ThisDrawing.SetVariable "OSMODE", Intersection 'snap to inersection
oPoint = ThisDrawing.Utility.GetPoint(, "Select Zero Point :") 'retrieve 0
point
ThisDrawing.SetVariable "OSMODE", PrevSnapSetting 'return snaps

For Each Ent In ThisDrawing.ModelSpace 'move everything
Ent.Move oPoint, UCSzero
Next

For Each Ent In SS1
If Ent.Layer = "0" Then
If TypeOf Ent Is AcadCircle Then
Set Circ = Ent
DefXpt(0) = -0.5: DefXpt(1) = Circ.center(1)
DefYpt(0) = Circ.center(0): DefYpt(1) = -0.5
Set Xdim = ThisDrawing.ModelSpace.AddDimOrdinate(Circ.center,
DefXpt, 0)
Set Ydim = ThisDrawing.ModelSpace.AddDimOrdinate(Circ.center,
DefYpt, 1)
ElseIf TypeOf Ent Is AcadBlockReference Then
Set BlkRef = Ent
DefXpt(0) = -0.5: DefXpt(1) = BlkRef.InsertionPoint(1)
DefYpt(0) = BlkRef.InsertionPoint(0): DefYpt(1) = -0.5
Set Xdim =
ThisDrawing.ModelSpace.AddDimOrdinate(BlkRef.InsertionPoint, DefXpt, 0)
Set Ydim =
ThisDrawing.ModelSpace.AddDimOrdinate(BlkRef.InsertionPoint, DefYpt, 1)
End If
End If
Next

For Each Ent In ThisDrawing.ModelSpace 'move everything back
Ent.Move UCSzero, oPoint
Next
SS1.Delete 'cleanup
ThisDrawing.ActiveLayer = ActivLayr
End Sub
0 Likes