|
||||||||||||||||||||||||||||||
|
AutoCAD Tips & TutorialsBreak objects quicklyMichael Tabacinic sent me this e-mail: "First off, I'd like to say, love your blog and love your tips; So helpful! Your tip doesn't exactly solve the issue, but it helps a little; I figured I
might as well ask:
Any idea how to achieve what I've been trying to do for weeks? (The CAD
manager said he'd look into a solution through lsp programming, but hasn't
found anything so far)"
But lots of interesting code came out of the process, so I thought I'd share it with you. I'm not a programmer, so anything I write is very amateurish. But here's what I came up with (note that I used bap instead of br): ;;;breaks object at the point you use to select it I sent this back to Michael, noting that it doesn't have any error trapping. Specifically, it just fails if you don't select an object. It defines a command, BAP, that asks for a break point. You can use an object snap. Then it breaks the object at that point. Meanwhile, I sent this to Lee Ambrosius of Hyperpics.com. Lee is a real programmer and he sent this back. He notes that even this code is missing some error trapping for the situation where a user presses Esc before breaking the line. (defun c:bap ( / object breakpoint) This code does the same thing as mine, but adds some error trapping and a couple of other nice features. Meanwhile, Michael replied: Thank you very much for your help Ellen. I used your LISP function to learn how LISP works, and then tweaked it to get it to do what I wanted. I'm not sure how well it works, as I'm not a programmer either, so I don't know if it's foolproof, but it does what I need it to so far. . . The main reason I had to tweak your version was because if two lines (or more) crossed each other, I could only use the command on the line that was on top in the drawing order, which wasn't always the one I wanted. There was another problem too, which my LISP command can't solve either. . . The problem is the following: The point I want too break a line at is where a 2nd line would intersect it if I were to extend it. To select this point, I drag an OTRACK line that extends from the 2nd line to the intersection. But when I click on the intersection, either the line stays intact, or the line breaks at a different point. When I perform the same actions using the "Break At Point" icon in the "Modify" toolbar, it does what I want it to. I'm not sure if it's a LISP thing, or if it has to do with my AutoCAD settings, or with the program itself, or something else. If you have any ideas on that, I'd love it if you could send them over hear to help me solve this... otherwise I'll have to settle for the tweaked LISP command..." Here is Michael's code: ;;;breaks selected object at the point you pick Now, you have four AutoLISP routines that can help you break objects quickly. You can see how even non-programmers can enjoy writing code and create something useful. Of course, you need to know something about AutoLISP, but amateurs can still create very useful programs. Give it a try!
|
|
|
|||||||||||||||||||||||||||
Home | AutoCAD | PowerPoint | E-Store
| About | Links | Contact | Site Map
|
||||||||||||||||||||||||||||||