Author Topic: Need help trimming objects  (Read 4735 times)

0 Members and 1 Guest are viewing this topic.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Need help trimming objects
« 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
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

Bryco

  • Water Moccasin
  • Posts: 1882
Re: Need help trimming objects
« Reply #1 on: January 20, 2007, 03:58:44 PM »
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.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: Need help trimming objects
« Reply #2 on: January 20, 2007, 04:50:35 PM »
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.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

SomeCallMeDave

  • Guest
Re: Need help trimming objects
« Reply #3 on: January 20, 2007, 06:04:17 PM »
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.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: Need help trimming objects
« Reply #4 on: January 20, 2007, 06:07:04 PM »
VBA has no trim method. I would have to use "send command" and that is just plain ugly.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

MickD

  • King Gator
  • Posts: 3619
  • (x-in)->[process]->(y-out) ... simples!
Re: Need help trimming objects
« Reply #5 on: January 20, 2007, 08:00:05 PM »
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.
« Last Edit: January 20, 2007, 08:03:53 PM by MickD »
"Short cuts make long delays,' argued Pippin.”
J.R.R. Tolkien

Bryco

  • Water Moccasin
  • Posts: 1882
Re: Need help trimming objects
« Reply #6 on: January 20, 2007, 09:28:35 PM »
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.
Code: [Select]
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

hendie

  • Guest
Re: Need help trimming objects
« Reply #7 on: January 21, 2007, 05:47:41 AM »
... 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

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: Need help trimming objects
« Reply #8 on: January 21, 2007, 11:22:50 AM »
But I want VB(A) ... because I will be compiling this into an executable
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

LE

  • Guest
Re: Need help trimming objects
« Reply #9 on: January 21, 2007, 07:56:38 PM »
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
« Last Edit: January 21, 2007, 08:00:28 PM by LE »

Bryco

  • Water Moccasin
  • Posts: 1882
Re: Need help trimming objects
« Reply #10 on: January 21, 2007, 08:26:58 PM »
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.

havano

  • Guest
Re: Need help trimming objects
« Reply #11 on: January 24, 2007, 03:54:19 AM »
If this clipping is done for cosmetic reasons, couldn't you use viewports (size, scale, align) to achieve your goal?

Bryco

  • Water Moccasin
  • Posts: 1882
Re: Need help trimming objects
« Reply #12 on: January 28, 2007, 07:58:07 PM »
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.

Tuoni

  • Gator
  • Posts: 3032
  • I do stuff, and things!
Re: Need help trimming objects
« Reply #13 on: January 29, 2007, 04:15:45 AM »
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) 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?

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: Need help trimming objects
« Reply #14 on: January 29, 2007, 08:40:51 AM »
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 ...
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie