Discussion Groups

All Discussion Groups » Visual LISP, AutoLISP and General Customization Issues

Thread: Inser block and break lines - Lisp works but not clean on exit


Permlink Replies: 44 - Last Post: May 2, 2009 10:19 AM Last Post By: drago2dmax
drago2dmax

Posts: 196
Registered: 10/16/08
Inser block and break lines - Lisp works but not clean on exit
Posted: Apr 3, 2009 4:55 PM
  Click to reply to this thread Reply
Attachment TERMINAL.zip (5.8 KB)


Hi.

I got this simple lisp routine which insert the block (see attached TERMINAL.dwg") and break the line(s) if line found.

The lisp works what i want, but its not clean on exit.

The problems is i allow for the worth case which inserted the block onto a intersection of a cross lines.

Please note the following possible scenario when insert the block (basepoint of the block is at centre)

ie.

- Insert the block but no lines for breakage

- Insert the block at the end of line (line start point)

- Insert the block at the other end of line (line end point)

- Insert the block at middle of line

- Insert the block at T-junction of 2 lines

- Insert the block at L-junction of 2 lines

- Insert the block at X-junction of 2 lines



Hence im allow these 2 command lines to break all possible points

;;;(command ".break" Pt1 Pt2 pt1 "")

;;;(command ".break" Pt3 Pt4 pt3 "")

Because if some breaking point are not found, autocad command lines echo the following:-





Command: inb Can't break a block

Can't break a block

Can't break a block

Can't break a block

Can't break a block

Can't break a block





Command: inb Can't break a block

Can't break a block

Can't break a block

Unknown command "INB". Press F1 for help.





Command: inb

Unknown command "INB". Press F1 for help.

Unknown command "INB". Press F1 for help.



As you can see from above command echos. Its not very clean on exit



Anyone be able to give a hand how to code it better to insert the block and only break/trim the lines as require.

What i mean is onlt break/trim if the breaking point of a line exist.



Thankyou in advance



;;;

(defun c:inb ()

(command ".insert" "TERMINAL" "S" "1" pause "0")

(command "draworder" "L" "" "b")

(brkline)

)



(defun brkline ()



(setq hbrklength 1.25)

(setq vbrklength 1.25)

(setq LASTBLK (entlast))

(setq GETLASTBLK (entget LASTBLK))

(setq ptp (cdr (assoc 10 GETLASTBLK)))

(setq Pt1 (polar Ptp 1.5708 hbrklength))

(setq Pt2 (polar Ptp (+ 1.5708 pi) hbrklength))

(setq Pt3 (polar Ptp 0 vbrklength))

(setq Pt4 (polar Ptp (+ 0 pi) vbrklength))



(setq pikbox (getvar "pickbox"))

(setvar "osmode" 0)

(setvar "pickbox" 1)



(command ".break" Pt1 Pt2 pt1 "")

(command ".break" Pt3 Pt4 pt3 "")



(setvar "pickbox" pikbox)



(princ))

;;;

Kent1Cooper

Posts: 1,119
Registered: 09/13/04
Re: Inser block and break lines - Lisp works but not clean on exit
Posted: Apr 3, 2009 5:48 PM   in response to: drago2dmax in response to: drago2dmax
  Click to reply to this thread Reply
Without analyzing it too deeply, it looks as though, under several of your scenarios, the Block [even if it's moved to the back of the drawing order] would be the *only thing* at some of those pick locations in the Break commands, which should explain your problem.

But if the Line(s) would *always* go to or through the center of the Circle in the Block, since it appears that's how the Block is being inserted, then you might try something like this, to Trim the Line(s) to the Circle part of the Block, rather than Break them [untested]:

(defun brkline (/ inspt)
  (setq inspt (cdr (assoc 10 (entget (entlast)))))
  (command "_.trim" (polar inspt 0 1.25) "" inspt inspt "")
)


That ought to select the Circle part as a Trim boundary if you're not using too old a version of AutoCAD. It ought to find it even if there's other stuff in the vicinity if the Block is the last oboject. Then it would pick at its center twice, looking for things to trim. In some cases it won't find that many [even none in your first scenario], but it should just go on and ask for another anyway, until the "" closes the Trim command. You could increase the number of times [the number of inspt entries near the end] if necessary.

--
Kent Cooper


drag02dmax wrote...
....
(defun brkline ()
(setq hbrklength 1.25)
(setq vbrklength 1.25)
(setq LASTBLK (entlast))
(setq GETLASTBLK (entget LASTBLK))
(setq ptp (cdr (assoc 10 GETLASTBLK)))
(setq Pt1 (polar Ptp 1.5708 hbrklength))
(setq Pt2 (polar Ptp (+ 1.5708 pi) hbrklength))
(setq Pt3 (polar Ptp 0 vbrklength))
(setq Pt4 (polar Ptp (+ 0 pi) vbrklength))
(setq pikbox (getvar "pickbox"))
(setvar "osmode" 0)
(setvar "pickbox" 1)
(command ".break" Pt1 Pt2 pt1 "")
(command ".break" Pt3 Pt4 pt3 "")
(setvar "pickbox" pikbox)
....
drago2dmax

Posts: 196
Registered: 10/16/08
Re: Inser block and break lines - Lisp works but not clean on exit
Posted: Apr 5, 2009 1:00 PM   in response to: Kent1Cooper in response to: Kent1Cooper
  Click to reply to this thread Reply
Thankyou Kent

The trim alternative could solve the issue if it was a simple block.

But some blocks i used are more complex then the one i posted here.

I was thinking something like NENTSELP "pt1, pt2, pt3, pt4" to test for existing entity and only break the point if entity is found.

Do you think this will work?

Thanks
stevor

Posts: 355
Registered: 12/26/05
Re: Inser block and break lines - Lisp works but not clean on exit
Posted: Apr 6, 2009 3:51 PM   in response to: drago2dmax in response to: drago2dmax
  Click to reply to this thread Reply
Since you appear to use a constant break gap, you could:
1. pick your insert pt first, as with getpoint,
2. search about that point with the calculated pts for crossing objects,
3. break the LINEs with the trim function, and other trimable objects,
4. and finally insert the block.
drago2dmax

Posts: 196
Registered: 10/16/08
Re: Inser block and break lines - Lisp works but not clean on exit
Posted: Apr 6, 2009 10:56 PM   in response to: stevor in response to: stevor
  Click to reply to this thread Reply
Hi Stevor

Thanks for the advice. The down side is when pick point first and insert block later is i dont get to see the block while inserting.

Not sure the trimming method going to works if the block contain lots of sub-entities inside the triming boundaries.
MelFranks
Re: Inser block and break lines - Lisp works but not clean on exit
Posted: Apr 6, 2009 7:45 PM   in response to: drago2dmax in response to: drago2dmax
  Click to reply to this thread Reply
Attachment inb.zip (904 bytes)


The attached should break any lines that cross
through your Terminal block.

Hope this is what you were looking
for.

 

Regards,

 

Mel

drago2dmax

Posts: 196
Registered: 10/16/08
Re: Inser block and break lines - Lisp works but not clean on exit
Posted: Apr 6, 2009 11:04 PM   in response to: MelFranks in response to: MelFranks
  Click to reply to this thread Reply
Thanks MelFranks

Initial test seems promising. I will test it with all different blocks and see if it works for all.

Im not verygood at interpreting visual lisp, what/why is the repeat 50 do???

;;;

(repeat 50

(setq plst

(cons

(polar ins-pt(setq st-ang(+ st-ang ang-inc))rad)

plst

)

)

)

;;;

Thankyou verymuch for the codes.
aak194

Posts: 63
Registered: 10/30/07
Re: Inser block and break lines - Lisp works but not clean on exit
Posted: Apr 13, 2009 4:39 AM   in response to: MelFranks in response to: MelFranks
  Click to reply to this thread Reply
Attachment Blocks.dwg (37.4 KB)
Hi MelFranks
I saw this INB.lsp which is good for terminal block. Can this be modified for attached drawing blocks.
Thanks
MelFranks
Re: Inser block and break lines - Lisp works but not clean on exit
Posted: Apr 13, 2009 6:42 PM   in response to: aak194 in response to: aak194
  Click to reply to this thread Reply
wrote in message news:6160891@discussion.autodesk.com...
Hi MelFranks I saw this INB.lsp which is good for terminal block. Can this be modified for attached drawing blocks. Thanks

When I get some time I can take a look at it.
Can you explain what results you are looking for in each case, maybe a before and after example?

Regards,

Mel
aak194

Posts: 63
Registered: 10/30/07
Re: Inser block and break lines - Lisp works but not clean on exit
Posted: Apr 14, 2009 5:11 AM   in response to: MelFranks in response to: MelFranks
  Click to reply to this thread Reply
Attachment Block-1.dwg (38.3 KB)
Hi MelFranks
Thanks for your reply.
Ok no problem when you have time then take a look.
Please see the attached example drawing file.
Regards
AAK
stevor

Posts: 355
Registered: 12/26/05
Re: Inser block and break lines - Lisp works but not clean on exit
Posted: Apr 14, 2009 1:19 PM   in response to: aak194 in response to: aak194
  Click to reply to this thread Reply
Did not use your example, but you may have to adjust the
search radius, rad, of (* 1.25 (vla-get-xscalefactor...
and the search circle center, ins-pt, of (vlax-safearray->list...
to get the break points you want.

If the temporary intersection CIRCLE object is created before the
(if (setq ss (ssget "cp" plst
and the program paused, then you can see the geometry.
MelFranks
Re: Inser block and break lines - Lisp works but not clean on exit
Posted: Apr 15, 2009 5:20 PM   in response to: aak194 in response to: aak194
  Click to reply to this thread Reply
Attachment blktrim.zip (16.9 KB)
I used the blocks that you originally attached, "90" and "T 63".
The program does not support blocks that are mirrored or non-orthogonal, or mlines, sorry.
Place your blocks and then select as many as you like and it will trim them all.
Hope it does what you are looking for.
I attached a drawing showing what it does, it seemed like the most logical outcome.

Regards,

Mel
aak194

Posts: 63
Registered: 10/30/07
Re: Inser block and break lines - Lisp works but not clean on exit
Posted: Apr 16, 2009 4:54 AM   in response to: MelFranks in response to: MelFranks
  Click to reply to this thread Reply
Hi MelFranks
It works great. I have very little knowledge about autolisps. I would like to see how can i change this lisps to another blocks.
Thanks very much
MelFranks
Re: Inser block and break lines - Lisp works but not clean on exit
Posted: Apr 16, 2009 1:13 PM   in response to: aak194 in response to: aak194
  Click to reply to this thread Reply
wrote in message news:6163291@discussion.autodesk.com...
Hi MelFranks It works great. I have very little knowledge about autolisps. I would like to see how can i change this lisps to
another blocks. Thanks very much

If you want to learn AutoLisp a good place to start is http://www.afralisp.net/.
As far as working for other blocks, any "T" or "L" shaped blocks that share the same orientation when inserted should work, we would
simply have to identify them in the routine.
In a nutshell, the program simply calculates the box that surrounds the block and uses those edges to trim, the method depending
upon the block's orientation.
If you post some other blocks I could look at them and see if they would be easily incorporated.

Regards,

Mel
drago2dmax

Posts: 196
Registered: 10/16/08
Re: Inser block and break lines - Lisp works but not clean on exit
Posted: Apr 16, 2009 1:45 PM   in response to: MelFranks in response to: MelFranks
  Click to reply to this thread Reply


Hi Melfranks

The lisp works great with slightly mod to works on many of my blocks with varying in sizes.



The BLKTRIM.lsp triming methods for AAK potentially be quite usefull for some of my other blocks. Wondering what is needed to make it works on all orientations/rotations?

Thankyou

MelFranks
Re: Inser block and break lines - Lisp works but not clean on exit
Posted: Apr 16, 2009 7:27 PM   in response to: drago2dmax in response to: drago2dmax
  Click to reply to this thread Reply
Attachment blktr.zip (17.7 KB)
wrote in message news:6163600@discussion.autodesk.com...

Hi Melfranks

The lisp works great with slightly mod to works on many of my blocks with varying in sizes.

The BLKTRIM.lsp triming methods for AAK potentially be quite usefull for some of my other blocks. Wondering what is needed to make
it works on all orientations/rotations?

Thankyou



The issue with trimming to blocks is that the IntersectWith method only returns points that intersect the bounding box of a
BlockRef.
If you rotate the block the bounding box returned is still orthogonal.
Assuming your blocks have horizontal and vertical edges you wish to trim with when inserted at zero degrees, the attached code
should trim with those edges at any block rotation or scale factor (including unequal) in the WCS. Mirrored blocks work as well.
It's not terribly elegant but appears to work.
I attached a drawing as an example.

Regards,

Mel
drago2dmax

Posts: 196
Registered: 10/16/08
Re: Inser block and break lines - Lisp works but not clean on exit
Posted: Apr 16, 2009 11:19 PM   in response to: MelFranks in response to: MelFranks
  Click to reply to this thread Reply


Hi Melfranks

Could you be able to also make it works on Round blocks and Straight edges one. Isn't round blocks also capable of returning boundingbox points? anyway i tried but doesn't seem to like it.

Verymuch appriciated

drago2dmax

Posts: 196
Registered: 10/16/08
Re: Inser block and break lines - Lisp works but not clean on exit
Posted: Apr 16, 2009 11:19 PM   in response to: MelFranks in response to: MelFranks
  Click to reply to this thread Reply


Hi Melfranks

Could you be able to also make it works on Round blocks and Straight edges one. Isn't round blocks also capable of returning boundingbox points? anyway i tried but doesn't seem to like it.

Verymuch appriciated

MelFranks
Re: Inser block and break lines - Lisp works but not clean on exit
Posted: Apr 17, 2009 1:15 PM   in response to: drago2dmax in response to: drago2dmax
  Click to reply to this thread Reply
Attachment blktr.lsp (2.5 KB)
wrote in message news:6164219@discussion.autodesk.com...

Hi Melfranks

Could you be able to also make it works on Round blocks and Straight edges one. Isn't round blocks also capable of returning
boundingbox points? anyway i tried but doesn't seem to like it.

Verymuch appriciated


Any block will return a bounding box but it is just that, a box.
I either don't understand what you are after or you don't understand what the code does.
Maybe you could post a drawing?
Run the attached code, the red lines are the cutting edges based on the block insertion angle, redraw will eliminate them.

Regards,

Mel
drago2dmax

Posts: 196
Registered: 10/16/08
Re: Inser block and break lines - Lisp works but not clean on exit
Posted: Apr 17, 2009 1:49 PM   in response to: MelFranks in response to: MelFranks
  Click to reply to this thread Reply
Attachment bloks.zip (25.0 KB)
Hi Melfranks

Im in the middle of testing it prior to your new post. Heres what happened, i could not get it to work on round blocks in my office pc running acad2008. Now im at home test it on acad2006, please see attached drawings.

Firstly the round blocks on "blocks3.dwg" works on first go, but when undo and retry again then it failed to trim.

Secondly, i created a new drawing "round-blocks.dwg" the round blocks doen't works at all. but the square one do works, but if i undo and try again then it failed.

Hope you understand what im trying to explain.

Really appriciating your effort. Thankyou
MelFranks
Re: Inser block and break lines - Lisp works but not clean on exit
Posted: Apr 17, 2009 3:31 PM   in response to: drago2dmax in response to: drago2dmax
  Click to reply to this thread Reply
Attachment blktr.zip (1.0 KB)
wrote in message news:6164553@discussion.autodesk.com...
Hi Melfranks

Im in the middle of testing it prior to your new post. Heres what happened, i could not get it to work on round blocks in my office
pc running acad2008. Now im at home test it on acad2006, please see attached drawings.

Firstly the round blocks on "blocks3.dwg" works on first go, but when undo and retry again then it failed to trim.

Secondly, i created a new drawing "round-blocks.dwg" the round blocks doen't works at all. but the square one do works, but if i
undo and try again then it failed.

Hope you understand what im trying to explain.

Really appriciating your effort. Thankyou


I had a couple of really stupid but difficult to find problems, give the attached a try.
It's days like this when I really feel like a rank amateur, considering the very talented people who post to this forum and no doubt
cringe looking at my code.
I figure though that the best way to learn is to do, and if it helps someone along the way so much the better, even if the code is
in some respects sub-par.
Have a great weekend.

Regards,

Mel
drago2dmax

Posts: 196
Registered: 10/16/08
Re: Inser block and break lines - Lisp works but not clean on exit
Posted: Apr 18, 2009 3:23 AM   in response to: MelFranks in response to: MelFranks
  Click to reply to this thread Reply
Thankyou Mel

You have a great weekend too.

I will spend some wkend hour trying figure out how to make it works on *Line, Arc, Circle, Ellipse. (spline maybe tough). At the moment i notice it only works on single vertex pline. If it ables to trim on those entities, then the program will be more user friendly.

Cheers
drago2dmax

Posts: 196
Registered: 10/16/08
Re: Inser block and break lines - Lisp works but not clean on exit
Posted: Apr 20, 2009 4:28 AM   in response to: MelFranks in response to: MelFranks
  Click to reply to this thread Reply
Hi Mel

I did attempt trying understand what the code is doing.

I assume the (ssget "cp" pts is selecting the crossing polygon of the start and end point of a line.



just wondering what happen if (ssget "cp" PTS '((0 . "*LINE,ARC,CIRCLE,ELLIPSE"))) and the PTS is the bounding box of a selection set of a group of blocks.

Do you think is it going to works? im still looking up examples of the selection set bounding box in this NG.

Thankyou
drago2dmax

Posts: 196
Registered: 10/16/08
Re: Inser block and break lines - Lisp works but not clean on exit
Posted: Apr 21, 2009 3:38 AM   in response to: MelFranks in response to: MelFranks
  Click to reply to this thread Reply
Attachment BLOK2.zip (22.7 KB)


Hi Mel.

Your codes is out of my league at this moment. I got this code from Jason Rhymes (see attached) thinking i could play around with your codes in replacing the "PTS" variable with the boundingbox of the selected blocks, well i got nowhere.



Mel. if you please could take another look at the attached drawings which trims the multi-vertex Pline, ARC and LINE.



Really apriciated that you put in your times to save other people's times.

MelFranks
Re: Inser block and break lines - Lisp works but not clean on exit
Posted: Apr 21, 2009 11:53 AM   in response to: drago2dmax in response to: drago2dmax
  Click to reply to this thread Reply
wrote in message news:6166445@discussion.autodesk.com...

Hi Mel.

Your codes is out of my league at this moment. I got this code from Jason Rhymes (see attached) thinking i could play around with
your codes in replacing the "PTS" variable with the boundingbox of the selected blocks, well i got nowhere.
Mel. if you please could take another look at the attached drawings which trims the multi-vertex Pline, ARC and LINE.


I can't open your drawing, I'm running AutoCAD 2006.

Regards,

Mel
drago2dmax

Posts: 196
Registered: 10/16/08
Re: Inser block and break lines - Lisp works but not clean on exit
Posted: Apr 21, 2009 1:39 PM   in response to: MelFranks in response to: MelFranks
  Click to reply to this thread Reply
Attachment blocks2.zip (21.7 KB)
Hi.



here it again in 2006 version



I just relise is the bounding box of a block taking into account the attributes outside the block, would it still works???



Please see attached, i have a sample of the attribute outside the block.

Sorry for the hassle, that would be it most of my blocks require trimming are either round or square and sometimes the attribute value need to move outside the block because if it consisted of more then 2 letters.

Thankyou

Edited by: drago2dmax on Apr 21, 2009 1:52 PM
MelFranks
Re: Inser block and break lines - Lisp works but not clean on exit
Posted: Apr 21, 2009 6:06 PM   in response to: drago2dmax in response to: drago2dmax
  Click to reply to this thread Reply
Attachment blktr.zip (957 bytes)
wrote in message news:6166681@discussion.autodesk.com...
Hi.
here it again in 2006 version
I just relise is the bounding box of a block taking into account the attributes outside the block, would it still works???
Please see attached, i have a sample of the attribute outside the block.
Sorry for the hassle, that would be it most of my blocks require trimming are either round or square and sometimes the attribute
value need to move outside the block because if it consisted of more then 2 letters.

Thankyou Edited by: drago2dmax on Apr 21, 2009 1:52 PM


Give the attached a try.
If your blocks are similar to the ones in your drawing this should work.
It does on the blocks in that drawing.
The attributes are included in the bounding box so if you have a lot of text outside the geometry it may miss the trimming geometry.
The mecanism for selecting the objects to trim is crude, basically just an "X" through the bounding box.
This will only work on blocks similar to the ones in your drawing where the geometry makes up the boundary.
If one were to use a polyline as the block boundary then a more sophisticated trim object selection method could be used by
offsettting the polyline and creating a fence based on the vertices.

Regards,

Mel
MelFranks
Re: Inser block and break lines - Lisp works but not clean on exit
Posted: Apr 21, 2009 6:52 PM   in response to: MelFranks in response to: MelFranks
  Click to reply to this thread Reply
Attachment blktr.zip (987 bytes)
I had an error, ironically, in my error handler.
Attached new file.

Regards,

Mel
drago2dmax

Posts: 196
Registered: 10/16/08
Re: Inser block and break lines - Lisp works but not clean on exit
Posted: Apr 22, 2009 1:39 PM   in response to: MelFranks in response to: MelFranks
  Click to reply to this thread Reply
Attachment blocks3.zip (120 bytes)
Thanks again Mel.

I tested the latest blktr.lsp on the uploaded "blocks2.dwg" and only 3 blocks on the second ARC failed to trim, but when i re-test the same drawing with all the blocks moved away from "0,0,0" say about X80,000,Y50,000 from 0,0 then unexpected results occured. Dont know why? but generally i noticed blocks on ARC was problematic and selecting group of blocks on different entities also problems.

Please see attached drawing for additional explaination as indicated with notes and comments. Many thanks to you Mel if you could help me out to trim all these blocks in this drawing. Cheers
MelFranks
Re: Inser block and break lines - Lisp works but not clean on exit
Posted: Apr 22, 2009 2:57 PM   in response to: drago2dmax in response to: drago2dmax
  Click to reply to this thread Reply
wrote in message news:6167710@discussion.autodesk.com...
Thanks again Mel.

I tested the latest blktr.lsp on the uploaded "blocks2.dwg" and only 3 blocks on the second ARC failed to trim, but when i re-test
the same drawing with all the blocks moved away from "0,0,0" say about X80,000,Y50,000 from 0,0 then unexpected results occured.
Dont know why? but generally i noticed blocks on ARC was problematic and selecting group of blocks on different entities also
problems.

Please see attached drawing for additional explaination as indicated with notes and comments. Many thanks to you Mel if you could
help me out to trim all these blocks in this drawing. Cheers

I cannot open the drawing, remember I'm on 2006.

Regards,

Mel
drago2dmax

Posts: 196
Registered: 10/16/08
Re: Inser block and break lines - Lisp works but not clean on exit
Posted: Apr 22, 2009 10:57 PM   in response to: MelFranks in response to: MelFranks
  Click to reply to this thread Reply
Attachment block4.zip (35.3 KB)
Sorry about this Mel



The files was 2006 but its corrupted (0kb). Please see attached drawing and created on the go in the office and dont have much text in it. will repost the previous version version once i got home. Not exactly sure if the move got to do with anything, but it failed to trim after the move. Thankyou

Edited by: drago2dmax on Apr 22, 2009 10:58 PM
MelFranks
Re: Inser block and break lines - Lisp works but not clean on exit
Posted: Apr 23, 2009 12:38 PM   in response to: drago2dmax in response to: drago2dmax
  Click to reply to this thread Reply
Attachment blktr.zip (968 bytes)
wrote in message news:6168271@discussion.autodesk.com...
Sorry about this Mel



The files was 2006 but its corrupted (0kb). Please see attached drawing and created on the go in the office and dont have much text
in it. will repost the previous version version once i got home. Not exactly sure if the move got to do with anything, but it failed
to trim after the move. Thankyou Edited by: drago2dmax on Apr 22, 2009 10:58 PM


The problem was that vla-explode was simply not exploding the blocks, I honestly have no idea why.
The Explode command would explode them fine.
(vl-catch-all-error-message) was returning "Automation Error. Invalid input".
I changed the code to use the Explode command.
You may see your attributes flash on the screen and the Trim command will do some muttering to the command line.
Also, if you are zoomed out too far you may get unexpected results.
I could have zoomed to each block to avoid this but found that it was quite annoying.
I also changed the trim lines to be based on the insertion point of the block so make sure the blocks insertion points are at the
center of the triming boundry.
So far all the blocks I have seen appear to be this way.
Hopefully you will find this code, while a bit clunky, at least functional.

Regards,

Mel
drago2dmax

Posts: 196
Registered: 10/16/08
Re: Inser block and break lines - Lisp works but not clean on exit
Posted: Apr 23, 2009 2:26 PM   in response to: MelFranks in response to: MelFranks
  Click to reply to this thread Reply


Thankyou Mel.

That made my day. Everything works. I think i will need sometimes to catch up with your codes, especially you have shown to me and the reader that there are so many way of trimming/breaking of entities inside a block. every version of the codes that you provided for me and AAK seems to be in different approach to codings depending on the block makeup and arrangements.



I have a few other blocks that i dont use very offten or in larger quantities to request for another version of the code. (ie. round and square blocks also but with extra entities such as centre lines for circle and diagonal line thru the square block etc).



Mel. i think its really cool to have "SUPER-TRIM" to trim whatever inside a block regardless of block type, style and the way blocks was created. instead of having different version of the codes to works with different blocks. I know an idea prop up pretty easily but to take all the possible block parameter into account is almost impossible.



Once again THANKYOU VERYMUCH and much APPRICIATED.

MelFranks
Re: Inser block and break lines - Lisp works but not clean on exit
Posted: Apr 23, 2009 3:04 PM   in response to: drago2dmax in response to: drago2dmax
  Click to reply to this thread Reply
wrote in message news:6168724@discussion.autodesk.com...

Thankyou Mel.

That made my day. Everything works. I think i will need sometimes to catch up with your codes, especially you have shown to me and
the reader that there are so many way of trimming/breaking of entities inside a block. every version of the codes that you provided
for me and AAK seems to be in different approach to codings depending on the block makeup and arrangements.
I have a few other blocks that i dont use very offten or in larger quantities to request for another version of the code. (ie. round
and square blocks also but with extra entities such as centre lines for circle and diagonal line thru the square block etc).
Mel. i think its really cool to have "SUPER-TRIM" to trim whatever inside a block regardless of block type, style and the way blocks
was created. instead of having different version of the codes to works with different blocks. I know an idea prop up pretty easily
but to take all the possible block parameter into account is almost impossible.

Once again THANKYOU VERYMUCH and much APPRICIATED.

I'm glad it works for you finally.
To be honest I really hate having to explode the block, it feels like swatting a fly with a slegde hammer when a simple rolled up
newspaper would do the job just as well.
I'm certain there is a way to access the block definition and translate the required points onto the block reference without
exploding it, when I get time I'm going to look at how that would work.

Regards,

Mel
drago2dmax

Posts: 196
Registered: 10/16/08
Re: Inser block and break lines - Lisp works but not clean on exit
Posted: Apr 23, 2009 10:40 PM   in response to: MelFranks in response to: MelFranks
  Click to reply to this thread Reply
Hi Mel.

The exploding method works fine for me as i know whick blocks can be trimmed using the lisp. but its difficult to pass the lisp to others without educating them the limitation of use. As i notice if the blocks is a bit more complex then the one i provided such as "block with circle and centreline", the lisp still manage to trim them, but left some exploded entities behind.

Cheers.
MelFranks
Re: Inser block and break lines - Lisp works but not clean on exit
Posted: May 1, 2009 4:37 PM   in response to: drago2dmax in response to: drago2dmax
  Click to reply to this thread Reply
Attachment trimblock.zip (56.8 KB)
wrote in message news:6169312@discussion.autodesk.com...
Hi Mel.

The exploding method works fine for me as i know whick blocks can be trimmed using the lisp. but its difficult to pass the lisp to
others without educating them the limitation of use. As i notice if the blocks is a bit more complex then the one i provided such as
"block with circle and centreline", the lisp still manage to trim them, but left some exploded entities behind.

Cheers.


Not sure if you are still following the forum or will see this.
I've been toying with some code to allow automatic trimming using blocks, I've attached the code along with a drawing you
provided in which I have converted your blocks to work with my code, I also included some others.
Read the header of the Lisp file for details.
Depending upon how you create your boundary you can produce some good results, some of my co-workers are finding it useful.
The obvious drawback, besides that one may be using third party software and blocks, is the overhead of additional block
definitions.
Just thought you might be interested.

Regards,

Mel
drago2dmax

Posts: 196
Registered: 10/16/08
Re: Inser block and break lines - Lisp works but not clean on exit
Posted: May 2, 2009 2:27 AM   in response to: MelFranks in response to: MelFranks
  Click to reply to this thread Reply
Thankyou Mel

very interesting way of trimming blocks

Creating a trimming boundary to ensure trimming consistency and accuratecy might be usefull for some difficult blocks.

I will look into it to see if i could make use of this trimming method.



May i suggest another way of trimming based on your "inb.lsp" codes whick works very well for me.

(defun c:inb ( / *error* plst etyp acad-doc mspace ang-inc st-ang ins-pt rad ss circ obj int-lst int plst sv-cmd)



Where the

(setq rad (* 1.25(vla-get-xscalefactor blk))



be replaced with user nentsel the circle for radius, line entity inside block for length, or one pline vertex length of a closed pline in the block, also allow user to enter trim/break distance or pick 2 points on screen for distance the above radius or length not available. Another idea is only allow to trim the same block.

ie. block-A with size 1, block-B with size 2 all lay on a common *line. say if i nentsel the circle of block-A then only filter out block-A for trimming/breaking, the down side is user have to do it a few times for different blocks.



Thankyou

Edited by: drago2dmax on May 2, 2009 9:53 AM
aak194

Posts: 63
Registered: 10/30/07
Re: Inser block and break lines - Lisp works but not clean on exit
Posted: Apr 17, 2009 7:32 AM   in response to: MelFranks in response to: MelFranks
  Click to reply to this thread Reply
Hi MelFranks
Thanks very much for your intrest and great help.
Dear I came very late in programming because i am now over fifties and at this stage is hard for me to learn programming language.

My work is ie; FROM ANYWHERE GET A GLASS OF WATER AND GIVE IT TO NEEDY OR THIRSTY PERSON.
When he use or drink that, my thirst automatically away. Most of the people did not know this useful forum.
I regularly see and look for discussions and get most of the things. Which is very useful for other people who are doing manually cad drafting.
Thanks again to you and other friends who spent times for others.
Regards
AAK
aak194

Posts: 63
Registered: 10/30/07
Re: Inser block and break lines - Lisp works but not clean on exit
Posted: Apr 20, 2009 8:26 AM   in response to: MelFranks in response to: MelFranks
  Click to reply to this thread Reply
Attachment Blocks2.dwg (43.2 KB)
Hi MelFranks
Please see the attached dwg file here in it the new blocks are added.
Regards
AAK
MelFranks
Re: Inser block and break lines - Lisp works but not clean on exit
Posted: Apr 20, 2009 7:33 PM   in response to: aak194 in response to: aak194
  Click to reply to this thread Reply
wrote in message news:6165528@discussion.autodesk.com...
Hi MelFranks Please see the attached dwg file here in it the new blocks are added. Regards AAK

First question: I assume you want the 45deg block trimmed at 45deg. insertion angles and the larger every 90deg?
Second: Are these the last 2 blocks?
I don't mind helping if I have time and there is an end in sight. I'm short on the former and unsure of the latter. :)

Regards,

Mel
stevor

Posts: 355
Registered: 12/26/05
Re: Inser block and break lines - Lisp works but not clean on exit
Posted: Apr 20, 2009 8:11 PM   in response to: MelFranks in response to: MelFranks
  Click to reply to this thread Reply
Mel since you appear to be on a trajectory towards authoring a generalized break and trim routine, an idea:

require. or option, a non printing trim boundary shape be included in the Block definition, or referenced independently.
MelFranks
Re: Inser block and break lines - Lisp works but not clean on exit
Posted: Apr 21, 2009 2:34 PM   in response to: stevor in response to: stevor
  Click to reply to this thread Reply
wrote in message news:6166178@discussion.autodesk.com...
Mel since you appear to be on a trajectory towards authoring a generalized break and trim routine, an idea: require. or option, a
non printing trim boundary shape be included in the Block definition, or referenced independently.

I agree, a trimming object within the block would probably be necessary for a "do all" solution, possibly make the outer perimeter
of the block a polyline that could be trimmed to.

Regards,

Mel
aak194

Posts: 63
Registered: 10/30/07
Re: Inser block and break lines - Lisp works but not clean on exit
Posted: Apr 21, 2009 2:54 AM   in response to: MelFranks in response to: MelFranks
  Click to reply to this thread Reply
Hi MelFranks
Sure these two blocks are the last.
AAK
MelFranks
Re: Inser block and break lines - Lisp works but not clean on exit
Posted: Apr 21, 2009 2:39 PM   in response to: aak194 in response to: aak194
  Click to reply to this thread Reply
Attachment blktrim.zip (24.0 KB)
wrote in message news:6166443@discussion.autodesk.com...
Hi MelFranks Sure these two blocks are the last. AAK

Attached is the program and a drawing I tested on, the same rules apply as the first two blocks.
It's assumed the blocks will be equally scaled.
If you have more blocks you can post them, if I find time I can try to add them to the program.
That is unless you have hundreds. :)

Regards,

Mel
aak194

Posts: 63
Registered: 10/30/07
Re: Inser block and break lines - Lisp works but not clean on exit
Posted: Apr 22, 2009 8:45 AM   in response to: MelFranks in response to: MelFranks
  Click to reply to this thread Reply
Hi MelFranks
Thank you very much.
Will met again in any other discussion soon.
Regards
AAK