Finding Extents Coordinates

Finding Extents Coordinates

Anonymous
Not applicable
1,294 Views
8 Replies
Message 1 of 9

Finding Extents Coordinates

Anonymous
Not applicable
Hi,

I need a way to determine the coordinates of the drawings current extents (the extents of the visible portion of the drawing).

I am trying to select objects into a selection set using their coordinates and I need to determine if they are visible on the screen to do this successfully.

Any ideas on finding this value?
0 Likes
1,295 Views
8 Replies
Replies (8)
Message 2 of 9

Anonymous
Not applicable
In objectArx i use AcDbDatabase::extmax and extmin.
Guess there must be equivalent in .Net

(found it, but it's not there in 2005)

/Matt



wrote in message news:[email protected]...
Hi,

I need a way to determine the coordinates of the drawings current extents
(the extents of the visible portion of the drawing).

I am trying to select objects into a selection set using their coordinates
and I need to determine if they are visible on the screen to do this
successfully.

Any ideas on finding this value?
0 Likes
Message 3 of 9

Anonymous
Not applicable
Give this a shot

~'J'~

Imports System
Imports System.Threading
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.Geometry
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.EditorInput
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.Interop
Imports Autodesk.AutoCAD.Interop.Common

Namespace DrawingVars

Public Class Zoomxtents
_
Public Sub DrawingExtents()
Dim ar As Array
ar = ZoomExt()
MsgBox("Lower Left Point:" & vbNewLine & ar(0) & " " & ar(1) & " " & ar(2) & _
vbNewLine & "Upper Right Point:" & vbNewLine & ar(3) & " " & ar(4) & " " & ar(5))
End Sub
Public Function ZoomExt() As Double()
Dim dwgBound(5) As Double
Dim VisMinpt As [Object]
Dim VisMaxpt As [Object]
Dim CurDB As Database = HostApplicationServices.WorkingDatabase
Dim acApp As AcadApplication = CType(Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication, AcadApplication)

Using tr As Transaction = CurDB.TransactionManager.StartTransaction
Try

VisMinpt = acApp.ActiveDocument.GetVariable("VSMIN")
Dim minPt As Point3d = New Point3d(CType(VisMinpt, Double()))
VisMaxpt = acApp.ActiveDocument.GetVariable("VSMAX")
Dim maxPt As Point3d = New Point3d(CType(VisMaxpt, Double()))
dwgBound(0) = minPt(0)
dwgBound(1) = minPt(1)
dwgBound(2) = minPt(2)
dwgBound(3) = maxPt(0)
dwgBound(4) = maxPt(1)
dwgBound(5) = maxPt(2)
Finally
CType(tr, IDisposable).Dispose()
End Try
End Using
Return dwgBound
End Function

End Class
End Namespace
0 Likes
Message 4 of 9

Anonymous
Not applicable
The EXTMIN and EXTMAX system variables are the last
computed extents, but may not necessarily be the current
extents. To compute that you must do a ZOOM/Extents,
then those variables will be accurate.

What is your reason for doing that as opposed to just
getting everything in the drawing via SelectAll() ?


--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006/2007
http://www.acadxtabs.com

wrote in message news:[email protected]...
Hi,

I need a way to determine the coordinates of the drawings current extents (the extents of the visible portion of the drawing).

I am trying to select objects into a selection set using their coordinates and I need to determine if they are visible on the screen to do this successfully.

Any ideas on finding this value?
0 Likes
Message 5 of 9

Anonymous
Not applicable
Thanks for all of the responses!!

I fugred if the object's coordinates are on screen then I am safe in attempting to selecting it.

I wouldn't think a selectAll would work as the objects need to be drawn on screen to be selectable. Also, I'd rather select a smallish area if I can.

The first method I tried was moving to each object that I need to select. However I found this is too jerky on the eyes and not comfortable to watch. I don't want to constantly move around on the screen as I go through each object I am interested in,

Now the plan is to check to see if the object is visible, if not then i will move to ensure it is in view before I select it.
0 Likes
Message 6 of 9

Anonymous
Not applicable
Why don't you trying saving a view name of the current view. Then you could iterate your coordinates, if they fall within the view boundries you should be good to go.
If any one has any other ideas I'm all ears


pat
0 Likes
Message 7 of 9

Anonymous
Not applicable
Patrick,

Sounds interesting, but I haven't worked with views before.

Can I get a code snippet to see what you mean?
0 Likes
Message 8 of 9

Anonymous
Not applicable
I have not had to create a view like that yet.
Here is what I have for getting a named view once it is created
Dim VT As ViewTable = CType(Trans.GetObject(DB.ViewTableId, OpenMode.ForRead), ViewTable)
Dim ED As Editor = Application.DocumentManager.MdiActiveDocument.Editor
Try

If VT.Has(strViewName) Then
Dim VTR As ViewTableRecord = CType(Trans.GetObject(VT(strViewName), OpenMode.ForRead), ViewTableRecord)

ED.SetCurrentView(VTR)
'VTR = Nothing
'ED = Nothing
Else
MsgBox("No View Found, need to create", MsgBoxStyle.OkOnly, "No View")
End If

I think working with the com object might be a easier way to go for creating a named view.


pat
0 Likes
Message 9 of 9

Anonymous
Not applicable
thanks Patrick I will work with it to see what I can come up with.
0 Likes