broncos15 Posted April 11, 2016 Posted April 11, 2016 I know that I am making a stupid mistake, but I am wondering why my code to select the just created object after the break command doesn't work. I have tried using different combinations of entget with entlast, but it just doesn't seem to work. My code is: (setq ent1 (entget (entlast)));;;I have also tried (car (entget (entlast))) and (entget (car (entlast))) but it doesn't work either. (vl-cmdf "._join" ent ent1 "") Where ent is the object selected that I ran the break command on. This is part of a bigger routine, which is why I am trying to break and then rejoin the pline. Quote
Grrr Posted April 12, 2016 Posted April 12, 2016 Looks right to me, except this question: Whats the quote for the "ent" expression? - does it have entget ? Quote
BIGAL Posted April 12, 2016 Posted April 12, 2016 You need at 1st pick to save the object ID then do break entlast will be the new object. Quote
broncos15 Posted April 12, 2016 Author Posted April 12, 2016 So the ent is assigned is assigned to (setq ent (car (entsel "\nSelect object to break and join: "))) Is this incorrect as well? Quote
Grrr Posted April 12, 2016 Posted April 12, 2016 I am not sure but you could try: (vl-cmdf "._join" (entget ent ) ent1 "") where: (setq ent1 (entget (car (entlast)))) Quote
broncos15 Posted April 12, 2016 Author Posted April 12, 2016 So I tried that and it still isn't working. I'm wondering if maybe the object id is changed so that the original object doesn't exist anymore and instead there are two new id's. Quote
Grrr Posted April 12, 2016 Posted April 12, 2016 I was thinkink that join command might work with selection set, so maybe constructing an empty ss, where those both are added into it might work. Quote
Tharwat Posted April 12, 2016 Posted April 12, 2016 If I may. Why don't you use the command Pedit instead? As described into your first post that you selected a polyline and ran the command break then after that you used entlast function to get the polyline divided and that is not enough to get the newly created piece of curve object. When you firstly selected the polyline to break and after running the command break and it is done just write codes using while function with entnext to retrieve the newly created objects. Good luck. Quote
broncos15 Posted April 12, 2016 Author Posted April 12, 2016 If I may. Why don't you use the command Pedit instead? As described into your first post that you selected a polyline and ran the command break then after that you used entlast function to get the polyline divided and that is not enough to get the newly created piece of curve object. When you firstly selected the polyline to break and after running the command break and it is done just write codes using while function with entnext to retrieve the newly created objects. Good luck. I am not using PEDIT because this is part of a larger routine involving feature lines that will be broken and then rejoined using the same technique instead of inserting a PI using the command because it can mess up the slopes of the feature lines. I hadn't thought of using the entnext function to accomplish this. I'll mess around with it and see what I can do. Thanks for the help and suggestions! Quote
broncos15 Posted April 26, 2016 Author Posted April 26, 2016 Tharwat, so I have tried to use your method, but it says that I have an empty selection set, which seems weird because there should be at least one new entity. My code is: (setq lastent (entlast)) (command "._AeccBreakFeatures" ent "_f") (princ "\nPick break point: ") (command pause "@") (while (setq lastEnt (entnext lastEnt)) (ssadd lastEnt ss) ) Quote
Tharwat Posted April 26, 2016 Posted April 26, 2016 Hi, I don't know about C3D so I tried my method in AutoCAD 2009 and it does have only the new created piece that left off from the implementation of break command, so it works here. Quote
broncos15 Posted April 26, 2016 Author Posted April 26, 2016 So I think I must have something wrong with how I am incorporating it then because I tried it with just a normal polyline and it still gives me the error "Error: bad argument type: lselsetp nil". I have looked through my code and I still can't figure it out. Thank you so much for helping me with this! My code with the normal break command is : ((setq pt (getpoint "\nPick break point: ")) (setq lastent (entlast)) (vl-cmdf "_.break" ent "_f" "_non" pt "_non" pt) (while (setq lastEnt (entnext lastEnt)) (ssadd lastEnt ss) ) ) Quote
Tharwat Posted April 26, 2016 Posted April 26, 2016 Give this a go: (setq ss (ssadd) lastent (entlast) pt (getpoint "\nPick break point: ") ) (vl-cmdf "_.break" "\\" "_f" "_non" pt "_non" pt) (while (setq lastent (entnext lastent)) (ssadd lastent ss) ) (sssetfirst nil ss) Quote
ymg3 Posted April 26, 2016 Posted April 26, 2016 Broncos, I believe your problem arise when you are breaking a close entity. When this is the case (entlast) will return you the wrong entity since no new entity was created by the command. So you probably need to test to know if you starting entity is a closed one (circle, ellipse, polyline) entlast Returns the name of the last nondeleted main object (entity) in the drawing ymg Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.