HowTo : Select Sub does not apply correctly in different views
Article | 41023795 |
Type | HowTo |
Product | Engine |
Version | 5.0.1.1034 |
Date Added | 11/25/2004 |
Submitted by | Christof Duvenbeck |
Keywords | |
Subject
Select Sub does not apply correctly in different views
Summary
The attached file is containing a polyline. Inside the polyline a text and a very small insert have been placed. The idea was to use "Polyline.GetBoundingBox" to get the two points needed for a window selection and then to finally window select with the surrounding rectangle of this polyline.
But selection set does not contain the three objects. It contains only the polyline.
Solution
Notice that VectorDraw at the moment does not support Crossing Polygon(selecting objects that intersects with a polyline or are inside that polyline). However this is added to our wish list.
Our Crossing selects the objects that intersects with the rectangle or are inside the rectangle.However this rectangle sides are parallel to your display view. That is the problem. The points you pass creates a rectangle that is different from the bounding box.
A workaround is to set the view to "VTOP",do your actions(like retrieving the selection set) and then re-set the view as it was before. You have to keep some values in order to recover the view like Axis3DRotations,TargetPoint,ViewCenter,ViewSize.
Take a look at the sample code below:
var = pl.GetBoundingBox
p1(0) = var(0)
p1(1) = var(1)
p1(2) = var(4)
p2(0) = var(2)
p2(1) = var(3)
p2(2) = var(5)
Dim rots As Variant
Dim targ As Variant
Dim vcen As Variant
Dim vsize As Double
'keep the values in order to retrieve the initial view
rots = VDraw.ActiveDocument.ActiveLayOut.Axis3DRotations
targ = VDraw.ActiveDocument.ActiveLayOut.TargetPoint
vcen = VDraw.ActiveDocument.ActiveLayOut.ViewCenter
vsize = VDraw.ActiveDocument.ActiveLayOut.ViewSize
'change the view to vtop in order to work correct the Select function
VDraw.Actions.DisableRedraw = True
VDraw.CommandAction.View3D "VTOP"
VDraw.Actions.DisableRedraw = False
VDraw.Utility.WorldToCCS (p1)
VDraw.Utility.WorldToCCS (p2)
Dim selset As vdSelection
Set selset = VDraw.ActiveDocument.Selections.Add("mysel")
selset.Select "C", p1, p2
'Now sel set has all the three entities.
"Recover the previous view
VDraw.ActiveDocument.ActiveLayOut.Axis3DRotations = rots
VDraw.ActiveDocument.ActiveLayOut.TargetPoint = targ
VDraw.ActiveDocument.ActiveLayOut.ViewCenter = vcen
VDraw.ActiveDocument.ActiveLayOut.ViewSize = vsize