TheSwamp
Code Red => VB(A) => Topic started by: Keith™ on January 20, 2007, 02:44:18 PM
-
Ok .. I am trying to make my life a little bit easier, but I am finding it at least a little bit difficult with regards to trimming an object along a fence or object where there might be a fence.
Problem ...
Create a cutaway of a larger plan using a selected point as the center of the cutaway.
I can use SelectByCrossing and use a fence represened by a series of points, but there is no effective method by which to trim all of the objects outside of that fence. For lines, I could check them individually and modify the endpoint to the intersection of the fence and line, but for circles I cannot and arcs it changes the look of the object.
Any ideas?
Thanks
-
For circles and ellipsis, delete them and draw the arcs.
For arcs change the start or end etc.
So there is lots of redrawing involved.
Blocks are difficult as without a wrapper, vba doesn't allow access to the clip.
However you can use sendcommand.
I'm not comletely sure what you want but it seems to me you get everything you want by making a block of the larger plan then use sendcommand to clip that to what you want.
-
unfortunately that is exactly what I don't want to do simply because the resulting objects frequently don't turn out like the original. Seems like Autodesk should have implemented some sort of trim method ...
I will keep looking .. otherwise I will have to write an object handler for each specific entity type.
-
What about drawing a polyline at the clip border, offsetting it 'x' amount, use both those polylines as trim boundaries then creating a fence at 0.5x to trim all the entities that cross both boundaries. Then you can erase all the objects remaining in the inner boundary if you need a 'hole' or erase all those entities that don't lie within the inner boundary, if you want to 'clip'.
It might not work for every entity, but it should get most of them. You will have to zoom to at least the extents for the largest boundary since trimming seems to, if I remember correctly, work only on objects that are visible on the screen.
-
VBA has no trim method. I would have to use "send command" and that is just plain ugly.
-
There used to be an express tool (under modify but I can't think of the name just now) but last time I looked for it on 2006 I didn't find it but it sounds like the tool you need. I used to use it regularly in 2d work for blow up details using circles.
It may still be there somewhere hidden away and may be worth a look.
-
Using a line to trim to, a picked point and the isleft function to decide what side is the keeper and cycle for
iPts = Ent.IntersectWith(oLine, acExtendNone), the hard part is all done.
Function isLeft(LineStart, LineEnd, pt) As Integer
Dim Ans As Double
Ans = ((LineEnd(0) - LineStart(0)) * (pt(1) - LineStart(1)) _
- (pt(0) - LineStart(0)) * (LineEnd(1) - LineStart(1)))
Ans = Round(Ans, 12)
If Ans > 0 Then isLeft = 1: Exit Function 'Pt is left of the line (CW)
If Ans < 0 Then isLeft = -1: Exit Function 'Pt is right of the line (CCW)
If Ans = 0 Then isLeft = 0
End Function
-
... but for circles I cannot and arcs it changes the look of the object.
Any ideas?
Thanks
If they are crossing the fence, a circle will become an arc with start and end angles coincident with the intersection points on the fence.
An arc shouldn't look "different" as it will only be the startangle or endangle that changes. Polylines could be a pig
Looks like you may have to write some wrappers !
btw, the cookie cutter lisp was called EXTRIM (express tools) and Dent posted one some time ago called Detail.lsp but I can't seem to find it, although that is Lisp it might give you some ideas
-
But I want VB(A) ... because I will be compiling this into an executable
-
Is there available the getSplitCurves Method from VB(A)... ?
If it is it will be much less complex to define the cutting edge and select all the objects to cut, then that method will generate the new objects base on the intersections found on that edge, and just remove the unwanted break parts... don't know
Here I showed a command done using that method in arx...
http://www.theswamp.org/index.php?topic=10568.msg134894#msg134894
-
I've been playing with The Curve.class by Frank Oquendo it really makes the polylines easy.
Set Cv.Entity = oPline
Dist = Cv.GetParameterAtPoint(P1)
Here you have fed the class the pline and the point(from Ent.IntersectWith) and the distance a double that shows the verticie number, eg 5.6 would mean the point is at .6 of the length from vertex 5 to vertex 6, Bob's your uncle.
I do have a problem with crashing using a new list of coordinates.
It works if the beginning coordinates are the same but starting from the cutting line out it throws a wobbler.
Shame, as a new pline takes more proprty matching.
-
If this clipping is done for cosmetic reasons, couldn't you use viewports (size, scale, align) to achieve your goal?
-
I've been playing with this a bit as I always wanted a trim function.
Trimming a polyline is harder than I thought.
Being lazy and using the intersectwith method just blew up on me.
Since there could be a zigzag line down the middle of the cutting line, the qty of intersection points can be huge, unfortunately the points seem to be in a random order and therefore useless as is.
Back to the drawing board.
-
unfortunately the points seem to be in a random order and therefore useless as is.
All the work I have ever done with IntersectWith() seems to give me a random order on the points (for reference: http://discussion.autodesk.com/thread.jspa?messageID=431889 (http://discussion.autodesk.com/thread.jspa?messageID=431889)) and I have always taken each entity and seen whether it crosses the line I wish to intersect, rather than whether the line crosses through it (I appreciate, however, that this would not work in your example of the zig zag)
If I want to trim a polyline purely for internal calculations, I will add any two objects which intersect to an array of regions and use the region boolean functions to end up with the shape I want left over. I don't know if this is of any use to you?
-
If this clipping is done for cosmetic reasons, couldn't you use viewports (size, scale, align) to achieve your goal?
That is not an option. The cutaway section will be used as a block to insert into another drawing. If it were only as simple as a polygonal viewport ...
-
Tuoni, good post, it looks better to find my own intersection points. The straight ones are easy, I'll mess with the others when I get time, I'm thinking translate the arc and the line back to zero then use the line and circle formula. If it works it will be handy as I can also return the segment number at the same time.
Tony's sort by distance is a good idea. I thought of doing that but using the distance of the point from the start doesn't always work but now I realise he is sorting bt distance along the polyline which sounds like it will always work.
Good there's still hope for the lazy way.
-
Tuoni, good post, it looks better to find my own intersection points
You're quite welcome :)