help with IntersectWith, doesnt always return lowest point first.

help with IntersectWith, doesnt always return lowest point first.

Anonymous
Not applicable
676 Views
7 Replies
Message 1 of 8

help with IntersectWith, doesnt always return lowest point first.

Anonymous
Not applicable
AutoCad2002
Win2000

How can I get the Intersect with to return the array with the lowest
selected points first,

example:
I have a rectangle and a vertical line drawn through it, depending on how I
draw that rectangle sometime the returned points are first the Upper
intersection,Lower intersection and sometimes they are Lower intersection,
Upper intersection - the latter is what I am aiming for. I need to insert
some blocks from the lower point to the higher point, the way I have it now
is to sporadic.

Without pasting to much useless, this is the intersection part:

''-----------------------------------------
If Me.optVertical.value = True Then
intPoints = objOutlineItem.IntersectWith(EachPLine, acExtendNone)
insertionPntOne(0) = intPoints(0)
insertionPntOne(1) = intPoints(1)
insertionPntOne(2) = intPoints(2)
insertionPntTwo(0) = intPoints(3)
insertionPntTwo(1) = intPoints(4)
insertionPntTwo(2) = intPoints(5)
Set blockRefObjLE = ThisDrawing.ModelSpace.InsertBlock(insertionPntTwo,
blkSstrand, 1#, 1#, 1#, 1.5708)
Set blockRefObjAN = ThisDrawing.ModelSpace.InsertBlock(insertionPntOne,
blkSanchor, 1#, 1#, 1#, 1.5708)

End If
''-----------------------------------------

AnyHelp, thanks
0 Likes
677 Views
7 Replies
Replies (7)
Message 2 of 8

Anonymous
Not applicable
Here I even found what I was talking about by
searching the web on an OLD acadx webpage:

 

This method is especially useful with coordinate
arrays returned by the IntersectWith method of AcadEntity (which does not return
intersection points in any particular order). Hence, this method can be used to
rearrange the order of a set of points on a curve where it is intersected by
another object, so that the intersection points are in their natural order of
traversal.

 


But thats for dealing with curves!

 
0 Likes
Message 3 of 8

Anonymous
Not applicable
Hi Jose,
Try using the insersectwith method of the acadline, then check the line's
angle property to determine if the points need to be reversed. Also be
cautious with the acextend options so that you don't accidentally grab
additional points. If that doesn't work for you, you will have to write
code that sorts the points by comparing the x and y elements.
-Josh

Jose Guia wrote:

> AutoCad2002
> Win2000
>
> How can I get the Intersect with to return the array with the lowest
> selected points first,
>
> example:
> I have a rectangle and a vertical line drawn through it, depending on how I
> draw that rectangle sometime the returned points are first the Upper
> intersection,Lower intersection and sometimes they are Lower intersection,
> Upper intersection - the latter is what I am aiming for. I need to insert
> some blocks from the lower point to the higher point, the way I have it now
> is to sporadic.
>
> Without pasting to much useless, this is the intersection part:
>
> ''-----------------------------------------
> If Me.optVertical.value = True Then
> intPoints = objOutlineItem.IntersectWith(EachPLine, acExtendNone)
> insertionPntOne(0) = intPoints(0)
> insertionPntOne(1) = intPoints(1)
> insertionPntOne(2) = intPoints(2)
> insertionPntTwo(0) = intPoints(3)
> insertionPntTwo(1) = intPoints(4)
> insertionPntTwo(2) = intPoints(5)
> Set blockRefObjLE = ThisDrawing.ModelSpace.InsertBlock(insertionPntTwo,
> blkSstrand, 1#, 1#, 1#, 1.5708)
> Set blockRefObjAN = ThisDrawing.ModelSpace.InsertBlock(insertionPntOne,
> blkSanchor, 1#, 1#, 1#, 1.5708)
>
> End If
> ''-----------------------------------------
>
> AnyHelp, thanks
>
>
>
0 Likes
Message 4 of 8

Anonymous
Not applicable
Josh,
*I have the noextend option so there is no accidental point grabbing,
*the acadline doesn't help I use acadentity because of my GetEntity
I think your right about the following:

>you will have to write
> code that sorts the points by comparing the x and y elements

Any ideas on how to do this ?

thanks,
joseguia



"Minkwitz Design" wrote in message
news:[email protected]...
> Hi Jose,
> Try using the insersectwith method of the acadline, then check the line's
> angle property to determine if the points need to be reversed. Also be
> cautious with the acextend options so that you don't accidentally grab
> additional points. If that doesn't work for you, you will have to write
> code that sorts the points by comparing the x and y elements.
> -Josh
>
> Jose Guia wrote:
>
> > AutoCad2002
> > Win2000
> >
> > How can I get the Intersect with to return the array with the lowest
> > selected points first,
> >
> > example:
> > I have a rectangle and a vertical line drawn through it, depending on
how I
> > draw that rectangle sometime the returned points are first the Upper
> > intersection,Lower intersection and sometimes they are Lower
intersection,
> > Upper intersection - the latter is what I am aiming for. I need to
insert
> > some blocks from the lower point to the higher point, the way I have it
now
> > is to sporadic.
> >
> > Without pasting to much useless, this is the intersection part:
> >
> > ''-----------------------------------------
> > If Me.optVertical.value = True Then
> > intPoints = objOutlineItem.IntersectWith(EachPLine, acExtendNone)
> > insertionPntOne(0) = intPoints(0)
> > insertionPntOne(1) = intPoints(1)
> > insertionPntOne(2) = intPoints(2)
> > insertionPntTwo(0) = intPoints(3)
> > insertionPntTwo(1) = intPoints(4)
> > insertionPntTwo(2) = intPoints(5)
> > Set blockRefObjLE =
ThisDrawing.ModelSpace.InsertBlock(insertionPntTwo,
> > blkSstrand, 1#, 1#, 1#, 1.5708)
> > Set blockRefObjAN =
ThisDrawing.ModelSpace.InsertBlock(insertionPntOne,
> > blkSanchor, 1#, 1#, 1#, 1.5708)
> >
> > End If
> > ''-----------------------------------------
> >
> > AnyHelp, thanks
> >
> >
> >
>
0 Likes
Message 5 of 8

Anonymous
Not applicable
The quote below relates to SortCurvePoints, which is a
method of the AcadXCurve class from AcadX.arx, and it
will sort the points on the curve based on their distance
from the start, but keep in mind that because it always
sorts the coordinates from the start of the curve (or in
the case of a LINE, from the StarPoint), if the line is
reversed, then you have the same problem all over again.

"Jose Guia" wrote in message
news:[email protected]...
> Here I even found what I was talking about by searching the web on an OLD
acadx webpage:
>
> This method is especially useful with coordinate arrays returned by the
IntersectWith method of AcadEntity (which does not return intersection
points in any particular order). Hence, this method can be used to rearrange
the order of a set of points on a curve where it is intersected by another
object, so that the intersection points are in their natural order of
traversal.
>
> http://members.bellatlantic.net/~vze2vjds/acadx/AcadX.htm
> But thats for dealing with curves!
>
>
0 Likes
Message 6 of 8

Anonymous
Not applicable
If the line will always be vertical or you always want to go from the
lowest point in the Y to the higher point,,,, where retval is the array
of points returned from intersectwith:

dim Lpt (0 to 2) as double, Upt (0 to 2) as double
if retval(1)>retval(4) then
Lpt(0)=retval(3):Lpt(1)=retval(4):Lpt(2)=0#'or retval(5)
Upt(0)=retval(0):Upt(1)=retval(1):Upt(2)=0#'or retval(2)
else
Lpt(0)=retval(0):Lpt(1)=retval(1):Lpt(2)=0#'or retval(2)
Upt(0)=retval(3):Upt(1)=retval(4):Upt(2)=0#'or retval(5)
end if


Jose Guia wrote:

> Josh,
> *I have the noextend option so there is no accidental point grabbing,
> *the acadline doesn't help I use acadentity because of my GetEntity
> I think your right about the following:
>
>
>>you will have to write
>>code that sorts the points by comparing the x and y elements
>>
>
> Any ideas on how to do this ?
>
> thanks,
> joseguia
>
>
>
> "Minkwitz Design" wrote in message
> news:[email protected]...
>
>>Hi Jose,
>>Try using the insersectwith method of the acadline, then check the line's
>>angle property to determine if the points need to be reversed. Also be
>>cautious with the acextend options so that you don't accidentally grab
>>additional points. If that doesn't work for you, you will have to write
>>code that sorts the points by comparing the x and y elements.
>>-Josh
>>
>>Jose Guia wrote:
>>
>>
>>>AutoCad2002
>>>Win2000
>>>
>>>How can I get the Intersect with to return the array with the lowest
>>>selected points first,
>>>
>>>example:
>>> I have a rectangle and a vertical line drawn through it, depending on
>>>
> how I
>
>>>draw that rectangle sometime the returned points are first the Upper
>>>intersection,Lower intersection and sometimes they are Lower
>>>
> intersection,
>
>>>Upper intersection - the latter is what I am aiming for. I need to
>>>
> insert
>
>>>some blocks from the lower point to the higher point, the way I have it
>>>
> now
>
>>>is to sporadic.
>>>
>>>Without pasting to much useless, this is the intersection part:
>>>
>>>''-----------------------------------------
>>>If Me.optVertical.value = True Then
>>> intPoints = objOutlineItem.IntersectWith(EachPLine, acExtendNone)
>>> insertionPntOne(0) = intPoints(0)
>>> insertionPntOne(1) = intPoints(1)
>>> insertionPntOne(2) = intPoints(2)
>>> insertionPntTwo(0) = intPoints(3)
>>> insertionPntTwo(1) = intPoints(4)
>>> insertionPntTwo(2) = intPoints(5)
>>> Set blockRefObjLE =
>>>
> ThisDrawing.ModelSpace.InsertBlock(insertionPntTwo,
>
>>>blkSstrand, 1#, 1#, 1#, 1.5708)
>>> Set blockRefObjAN =
>>>
> ThisDrawing.ModelSpace.InsertBlock(insertionPntOne,
>
>>>blkSanchor, 1#, 1#, 1#, 1.5708)
>>>
>>>End If
>>>''-----------------------------------------
>>>
>>>AnyHelp, thanks
>>>
>>>
>>>
>>>
>
>
0 Likes
Message 7 of 8

Anonymous
Not applicable
I see, kinda makes me wonder why I didn't think of that.

I'll try later today and re-post.


thanks for your help!

joseguia



"Minkwitz Design" wrote in message
news:[email protected]...
> If the line will always be vertical or you always want to go from the
> lowest point in the Y to the higher point,,,, where retval is the array
> of points returned from intersectwith:
>
> dim Lpt (0 to 2) as double, Upt (0 to 2) as double
> if retval(1)>retval(4) then
> Lpt(0)=retval(3):Lpt(1)=retval(4):Lpt(2)=0#'or retval(5)
> Upt(0)=retval(0):Upt(1)=retval(1):Upt(2)=0#'or retval(2)
> else
> Lpt(0)=retval(0):Lpt(1)=retval(1):Lpt(2)=0#'or retval(2)
> Upt(0)=retval(3):Upt(1)=retval(4):Upt(2)=0#'or retval(5)
> end if
>
>
> Jose Guia wrote:
>
> > Josh,
> > *I have the noextend option so there is no accidental point grabbing,
> > *the acadline doesn't help I use acadentity because of my GetEntity
> > I think your right about the following:
> >
> >
> >>you will have to write
> >>code that sorts the points by comparing the x and y elements
> >>
> >
> > Any ideas on how to do this ?
> >
> > thanks,
> > joseguia
> >
> >
> >
> > "Minkwitz Design" wrote in message
> > news:[email protected]...
> >
> >>Hi Jose,
> >>Try using the insersectwith method of the acadline, then check the
line's
> >>angle property to determine if the points need to be reversed. Also be
> >>cautious with the acextend options so that you don't accidentally grab
> >>additional points. If that doesn't work for you, you will have to write
> >>code that sorts the points by comparing the x and y elements.
> >>-Josh
> >>
> >>Jose Guia wrote:
> >>
> >>
> >>>AutoCad2002
> >>>Win2000
> >>>
> >>>How can I get the Intersect with to return the array with the lowest
> >>>selected points first,
> >>>
> >>>example:
> >>> I have a rectangle and a vertical line drawn through it, depending on
> >>>
> > how I
> >
> >>>draw that rectangle sometime the returned points are first the Upper
> >>>intersection,Lower intersection and sometimes they are Lower
> >>>
> > intersection,
> >
> >>>Upper intersection - the latter is what I am aiming for. I need to
> >>>
> > insert
> >
> >>>some blocks from the lower point to the higher point, the way I have it
> >>>
> > now
> >
> >>>is to sporadic.
> >>>
> >>>Without pasting to much useless, this is the intersection part:
> >>>
> >>>''-----------------------------------------
> >>>If Me.optVertical.value = True Then
> >>> intPoints = objOutlineItem.IntersectWith(EachPLine, acExtendNone)
> >>> insertionPntOne(0) = intPoints(0)
> >>> insertionPntOne(1) = intPoints(1)
> >>> insertionPntOne(2) = intPoints(2)
> >>> insertionPntTwo(0) = intPoints(3)
> >>> insertionPntTwo(1) = intPoints(4)
> >>> insertionPntTwo(2) = intPoints(5)
> >>> Set blockRefObjLE =
> >>>
> > ThisDrawing.ModelSpace.InsertBlock(insertionPntTwo,
> >
> >>>blkSstrand, 1#, 1#, 1#, 1.5708)
> >>> Set blockRefObjAN =
> >>>
> > ThisDrawing.ModelSpace.InsertBlock(insertionPntOne,
> >
> >>>blkSanchor, 1#, 1#, 1#, 1.5708)
> >>>
> >>>End If
> >>>''-----------------------------------------
> >>>
> >>>AnyHelp, thanks
> >>>
> >>>
> >>>
> >>>
> >
> >
>
0 Likes
Message 8 of 8

Anonymous
Not applicable
Worked like a champ!


thanks,

joseguia


"Jose Guia" wrote in message
news:[email protected]...
> I see, kinda makes me wonder why I didn't think of that.
>
> I'll try later today and re-post.
>
>
> thanks for your help!
>
> joseguia
>
>
>
> "Minkwitz Design" wrote in message
> news:[email protected]...
> > If the line will always be vertical or you always want to go from the
> > lowest point in the Y to the higher point,,,, where retval is the array
> > of points returned from intersectwith:
> >
> > dim Lpt (0 to 2) as double, Upt (0 to 2) as double
> > if retval(1)>retval(4) then
> > Lpt(0)=retval(3):Lpt(1)=retval(4):Lpt(2)=0#'or retval(5)
> > Upt(0)=retval(0):Upt(1)=retval(1):Upt(2)=0#'or retval(2)
> > else
> > Lpt(0)=retval(0):Lpt(1)=retval(1):Lpt(2)=0#'or retval(2)
> > Upt(0)=retval(3):Upt(1)=retval(4):Upt(2)=0#'or retval(5)
> > end if
> >
> >
> > Jose Guia wrote:
> >
> > > Josh,
> > > *I have the noextend option so there is no accidental point grabbing,
> > > *the acadline doesn't help I use acadentity because of my GetEntity
> > > I think your right about the following:
> > >
> > >
> > >>you will have to write
> > >>code that sorts the points by comparing the x and y elements
> > >>
> > >
> > > Any ideas on how to do this ?
> > >
> > > thanks,
> > > joseguia
> > >
> > >
> > >
> > > "Minkwitz Design" wrote in message
> > > news:[email protected]...
> > >
> > >>Hi Jose,
> > >>Try using the insersectwith method of the acadline, then check the
> line's
> > >>angle property to determine if the points need to be reversed. Also be
> > >>cautious with the acextend options so that you don't accidentally grab
> > >>additional points. If that doesn't work for you, you will have to
write
> > >>code that sorts the points by comparing the x and y elements.
> > >>-Josh
> > >>
> > >>Jose Guia wrote:
> > >>
> > >>
> > >>>AutoCad2002
> > >>>Win2000
> > >>>
> > >>>How can I get the Intersect with to return the array with the lowest
> > >>>selected points first,
> > >>>
> > >>>example:
> > >>> I have a rectangle and a vertical line drawn through it, depending
on
> > >>>
> > > how I
> > >
> > >>>draw that rectangle sometime the returned points are first the Upper
> > >>>intersection,Lower intersection and sometimes they are Lower
> > >>>
> > > intersection,
> > >
> > >>>Upper intersection - the latter is what I am aiming for. I need to
> > >>>
> > > insert
> > >
> > >>>some blocks from the lower point to the higher point, the way I have
it
> > >>>
> > > now
> > >
> > >>>is to sporadic.
> > >>>
> > >>>Without pasting to much useless, this is the intersection part:
> > >>>
> > >>>''-----------------------------------------
> > >>>If Me.optVertical.value = True Then
> > >>> intPoints = objOutlineItem.IntersectWith(EachPLine, acExtendNone)
> > >>> insertionPntOne(0) = intPoints(0)
> > >>> insertionPntOne(1) = intPoints(1)
> > >>> insertionPntOne(2) = intPoints(2)
> > >>> insertionPntTwo(0) = intPoints(3)
> > >>> insertionPntTwo(1) = intPoints(4)
> > >>> insertionPntTwo(2) = intPoints(5)
> > >>> Set blockRefObjLE =
> > >>>
> > > ThisDrawing.ModelSpace.InsertBlock(insertionPntTwo,
> > >
> > >>>blkSstrand, 1#, 1#, 1#, 1.5708)
> > >>> Set blockRefObjAN =
> > >>>
> > > ThisDrawing.ModelSpace.InsertBlock(insertionPntOne,
> > >
> > >>>blkSanchor, 1#, 1#, 1#, 1.5708)
> > >>>
> > >>>End If
> > >>>''-----------------------------------------
> > >>>
> > >>>AnyHelp, thanks
> > >>>
> > >>>
> > >>>
> > >>>
> > >
> > >
> >
>
>
0 Likes