Zoom to view in drawing:

Zoom to view in drawing:

Mike.Wohletz
Collaborator Collaborator
1,820 Views
12 Replies
Message 1 of 13

Zoom to view in drawing:

Mike.Wohletz
Collaborator
Collaborator
I have a program that either cycles through all the base views of a drawing or works with a selected view and pushes properties that I need in the drawing file back to the part or assembly file, currently I am showing what view is being edited by selecting it so that it shows up with this:

{code}

oDoc.SelectSet.Select(oView)

{code}

This gives the user an idea of what is going on at that time and if they need to include or exclude any information. My question is how can I zoom to that view rather than selecting it since it can be hard to see the little dotted selection line of a view.
1,821 Views
12 Replies
Replies (12)
Message 2 of 13

Anonymous
Not applicable
Try the following macro. Select a drawing view before running it.

Sanjay-


Sub ZoomToDrawingView()

Dim oDoc As DrawingDocument
Set oDoc = ThisApplication.ActiveDocument

Dim oDrawingView As DrawingView
Set oDrawingView = oDoc.SelectSet.Item(1)

Dim oTG As TransientGeometry
Set oTG = ThisApplication.TransientGeometry

Dim oView As View
Set oView = ThisApplication.ActiveView

Dim oCamera As Camera
Set oCamera = oView.Camera

Dim oEyePt As Point
Set oEyePt = oTG.CreatePoint(oDrawingView.Center.X,
oDrawingView.Center.Y, oCamera.Eye.Z)
oCamera.Eye = oEyePt

Dim oTargetPt As Point
Set oTargetPt = oTG.CreatePoint(oDrawingView.Center.X,
oDrawingView.Center.Y, oCamera.Target.Z)
oCamera.Target = oTargetPt

Call oCamera.SetExtents(oDrawingView.Width * 2, oDrawingView.Height * 2)

oCamera.Apply

End Sub
Message 3 of 13

Anonymous
Not applicable
I just had an interesting thought. What if you could SetExtents based the view and all annotations (or other geometry if applicable) associated to the view. In other words, calculate a tight box around everything associated to that view. Starting with the view as the parent, can I loop through all its child objects (I'm assuming 2d geometry of the model) and then any associated annotations. I would need to somehow be able to calculate a rangebox (may have to be a Collection of Box2d) of where each object exists in sheet space. iterate through all those rangebox to figure a min X, max X min Y & max Y (i.e. a rangebox containing all geometry associated to the view).
0 Likes
Message 4 of 13

Anonymous
Not applicable
Yes, that would be useful. and would be possible to do in the way that you
outlined (most drawing objects now support a RangeBox property). There are
still a few annotations that the API doesn't support (welding symbols,
etc.) - but not too many.

Sanjay-
0 Likes
Message 5 of 13

Anonymous
Not applicable
Can you get me started? Looking at the View object, I can't see a Property that leads me to the 2D geometry on the View. Also, how do I obtain object associated to views like balloons, dimensions, etc (i.e. parent child relationship)?
0 Likes
Message 6 of 13

Anonymous
Not applicable
A view in a drawing is represented by a DrawingView object. However,
annotations (such as notes, balloons, etc.) are on the Sheet object. You'd
have to iterate over the annotations on a sheet and filter out the ones that
are associated with a drawing view. The process to get the associated view
is, unfortunately, different for each annotation. For a balloon,
Balloon.ParentView provides that information. But for other annotations,
you'll need to drill down to the geometry they attach to and hence get to
the associated view.

Sanjay-
0 Likes
Message 7 of 13

Anonymous
Not applicable
Ok but I need a little more detail. I can't see how to drill down. Can you give me one short example (pseudo code)? I'm looking at the members of the GeneralDimension for instance and I can't tell which member contains the data I need. Even if I did know, whats the data's name that gets me the associated view?
0 Likes
Message 8 of 13

Anonymous
Not applicable
All I need is a nudge in the right direction. I've been poking around the API and can't see the realtionship bewteen and Annotation and its View.
0 Likes
Message 9 of 13

Anonymous
Not applicable
Sorry I haven't been following this thread, but from what you say here, I
would suspect if you stepped up the Parent structure of the annotation you
would eventually get to the view. ie.... oannotation.parent.parent.....etc.

--
KWiKMcad
Kent Keller
"Cadfish1" wrote in message news:[email protected]...
All I need is a nudge in the right direction. I've been poking around the
API and can't see the realtionship bewteen and Annotation and its View.
0 Likes
Message 10 of 13

Anonymous
Not applicable
Consider the case of a linear general dimension.This is represented by the
LinearGeneralDimension object (which derives from GeneralDimension). The
following will return the first drawing curve (DrawingCurve object) that the
dimension is attached to: LinearGeneralDimension.IntentOne.Geometry.
Finally, DrawingCurve.Parent returns the drawing view that contains this
curve.

You'll need to similarly special case each annotation.

Sanjay-
0 Likes
Message 11 of 13

Anonymous
Not applicable
Thanks Sanjay & Kent.
0 Likes
Message 12 of 13

kiruba
Contributor
Contributor

Thanks Sanjay,

i was stuck at this stage while attempting drawingview.camera.saveasbimap. It was giving "not implemented" error; your solution has given a workaround.

Digital Automation in Design Transformation
0 Likes
Message 13 of 13

miechh
Collaborator
Collaborator

The given solution works for me as well! Thanks!


Product Design Suite 2024
Inventor 2024 (v 28.20.27200.0000), Vault Basic 2024
Fusion 360
HP Workstation Z4
Intel Xeon 3.4GHz
32GB RAM
Windows 11 Professional (64bit)
0 Likes