MrCocopuffz Posted May 16, 2018 Share Posted May 16, 2018 Hello everyone. I'm trying to put together a lisp to be able to select a line, which will cause all the lines on that layer to be selected, then using the join command will make any lines connected at the endpoints to become a poly lines. I'm using some code from other lisps and trying to make this work. If I enter each line in on the command line it seems to work but when I use the new command "JLL" nothing really happens. It goes through the process of selecting everything but does not join. (defun C:JLL () (setq targetEnt (car (entsel "\nSelect object on layer to select: "))) (setq targetLayer (assoc 8 (entget targetEnt))) (sssetfirst nil (ssget "_X" (list targetLayer))) (command "join" "") (princ) ) Quote Link to comment Share on other sites More sharing options...
rkmcswain Posted May 16, 2018 Share Posted May 16, 2018 In AutoCAD, try running it with QAFLAGS = 1 Interestingly, it works fine in BricsCAD with QAFLAGS = 0 (the default) Quote Link to comment Share on other sites More sharing options...
MrCocopuffz Posted May 16, 2018 Author Share Posted May 16, 2018 It works!!! Thank you so much. Quote Link to comment Share on other sites More sharing options...
rkmcswain Posted May 17, 2018 Share Posted May 17, 2018 I would suggest setting that sysvar in the routine, and returning it to a value of 0 when you're done. QAFLAGS at a non-zero value can cause other oddities Quote Link to comment Share on other sites More sharing options...
MrCocopuffz Posted May 17, 2018 Author Share Posted May 17, 2018 Good to know, thanks for the help. Quote Link to comment Share on other sites More sharing options...
MrCocopuffz Posted May 17, 2018 Author Share Posted May 17, 2018 Would I place (setvar "qaflags" 1) right above the (command "join" "") or under (defun C:JLL ()? Or does it matter? Quote Link to comment Share on other sites More sharing options...
MrCocopuffz Posted May 17, 2018 Author Share Posted May 17, 2018 So I'm watching the text window as it executes and it looks like this: Command: jll Select object on layer to select: join 1340 found 5 objects converted to 1 polyline, 1333 objects discarded from the operation Command: JLL Unknown command "JLL". Press F1 for help. Why is it giving me an additionall "JLL" and "Unknown command" at the end? Quote Link to comment Share on other sites More sharing options...
tombu Posted May 17, 2018 Share Posted May 17, 2018 This works using initcommandversion without qaflags: (defun C:JLL () (setq targetEnt (car (entsel "\nSelect object on layer to select: "))) (setq targetLayer (assoc 8 (entget targetEnt))) (sssetfirst nil (ssget "_X" (list targetLayer))) (initcommandversion 2) (command-s "join" "") (princ) ) Quote Link to comment Share on other sites More sharing options...
MrCocopuffz Posted May 17, 2018 Author Share Posted May 17, 2018 This works using initcommandversion without qaflags:(defun C:JLL () (setq targetEnt (car (entsel "\nSelect object on layer to select: "))) (setq targetLayer (assoc 8 (entget targetEnt))) (sssetfirst nil (ssget "_X" (list targetLayer))) (initcommandversion 2) (command-s "join" "") (princ) ) For some reason, this version doesn't work for me. It asks for the selection but then nothing after. Quote Link to comment Share on other sites More sharing options...
tombu Posted May 17, 2018 Share Posted May 17, 2018 Odd, for me the Command or Text window displays: Command: JLL Select object on layer to select: join 3 found 3 objects converted to 1 polyline Command: after selecting one line it joined it with 2 other lines that shared endpoints. What did your Command or Text window display after you selected a line? Quote Link to comment Share on other sites More sharing options...
MrCocopuffz Posted May 17, 2018 Author Share Posted May 17, 2018 Odd, for me the Command or Text window displays:Command: JLL Select object on layer to select: join 3 found 3 objects converted to 1 polyline Command: after selecting one line it joined it with 2 other lines that shared endpoints. What did your Command or Text window display after you selected a line? This is a copy/paste from the text window: Command: JLL Select object on layer to select: _.join 5 found 5 objects converted to 1 polyline Command: JLL Unknown command "JLL". Press F1 for help. It's executing the command correctly, joining the lines, then it simply adds a "JLL" at the command line adding "unknown command" after. Looking around at other code is there something like CMDECHO or something I need? Quote Link to comment Share on other sites More sharing options...
tombu Posted May 17, 2018 Share Posted May 17, 2018 That's even stranger, the JLL command works then is an unknown command when JLL is relaunched for some unknown reason? JLL couldn't have worked if JLL was an unknown command. While it's still defined in the drawing run JLL and select connecting lines on another layer to see if it returns the same. Quote Link to comment Share on other sites More sharing options...
MrCocopuffz Posted May 17, 2018 Author Share Posted May 17, 2018 Yes, it works perfectly. I type JLL and select a line and all the lines connected on that layer are connected. Then I can simply hit spacebar and continue again for a line on a different layer. Here's the replay: Command: JLLSelect object on layer to select: _.join 1340 found 5 objects converted to 1 polyline, 1333 objects discarded from the operation Command: JLL Unknown command "JLL". Press F1 for help. Command: Command: JLL Select object on layer to select: _.join 7 found 7 objects converted to 1 polyline Command: JLL Unknown command "JLL". Press F1 for help. I tried changing the command to _.join to see if there was any difference. Quote Link to comment Share on other sites More sharing options...
tombu Posted May 17, 2018 Share Posted May 17, 2018 Glad it worked out. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted May 18, 2018 Share Posted May 18, 2018 Joining lines can be done form the command line no code its part of the pedit command, Ellen Finklestein has an article on how to do it over at cadalyst. Will try to find. Quote Link to comment Share on other sites More sharing options...
tombu Posted May 18, 2018 Share Posted May 18, 2018 For joining lines on the same layer I'd use GETSEL to select all lines on a selected layer and the JOIN command to join them. Good starter lisp routine though. I try to avoid modifying Dimension and Expert Variables that affect other things when I can, but as long as you include a local *error* function to make sure they're reset you should be fine. Quote Link to comment Share on other sites More sharing options...
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.