Jump to content

Join lines on same layer


MrCocopuffz

Recommended Posts

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)
)

Link to comment
Share on other sites

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

Link to comment
Share on other sites

Would I place (setvar "qaflags" 1) right above the (command "join" "") or under (defun C:JLL ()? Or does it matter?

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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)
)

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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: 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.

 

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...