Ok, I'll post the code I use - I don't know if
it'll help or not.
Set AcadApp =
CreateObject("Autocad.application")
Dim Thisdrawing As AcadDocument
FileNm = ActiveCell.Value Set
Thisdrawing =
AcadApp.Documents.Open(FileNm)
AutoCAD.Application.Visible = True
Dim Name As String Dim BlockRef As
AcadBlockReference Dim ss As
AcadSelectionSet
'Loop through the array NameList
to see if the drawing has a block by one of the following names - if so, select
it NameList = Array("HZ-PIDSTP",
"HZ-NSTP", "HZ-BEAVER", "HZ-STAMP",
"HZ-SSTP") Dim i As
Integer i =
0 Set ss =
Thisdrawing.PickfirstSelectionSet
ss.Clear Do While ss.Count = 0 And
i <= 4 Name =
NameList(i) Set ss =
Thisdrawing.PickfirstSelectionSet
ss.Clear Dim vt(0 To 1) As
Integer vt(0) = 0: vt(1) =
2 ss.Select acSelectionSetAll, , ,
vt, Array("INSERT", Name) If
ss.Count > 0
Then Set
BlockRef = ss(0) End
If i = i +
1
Loop
'Get the coordinates of
the block Dim BlockCoords As
Variant Dim NewCoords(0 To 2) As
Double Dim RasterScale As
Double BlockCoords =
BlockRef.InsertionPoint
This is the code I use. It works
perfectly fine when the block is on the layer "DIMENSION", but when it is on
another layer, it doesn't seem to work. Maybe this is just coincidence or
something. I just know that this is bugging me - it should work! If
you have any suggestions, that would be great.
Thanks
"TomD"
wrote in message news:[email protected]...
I think you're going to have give us some more
info. I'm 99% comfortable saying that there is no way the layer of the
block could have any effect on your insertion point. (I don't want to
say 100%, 'cause without details, you just never know.)
If possible, describe exactly the steps leading
up to and including the point at which you're extracting the
coordinates. (I've been using Acad for over 10 years, but I just started
dabbling with VBA over the last few years.)
"SomeGuy" wrote in
message news:[email protected]'ve
looked, and the drawing doesn't use UCS - it's WCS. After lots of testing I
think the problem might be that on the drawings that it's (edited) up my
coordinates for, the block reference is on a different layer. Now, I've
never really used AutoCAD before so this might just be totally wrong, but if
this is the problem - how do I fix it? (do I change the layer of the block?
change the active layer I'm on?) Thanks in
advance!