Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Select object between two points and join them

33 REPLIES 33
SOLVED
Reply
Message 1 of 34
arunkumar_selvarajan
1374 Views, 33 Replies

Select object between two points and join them

I required a LSIP program to select between first point and second point and then it should be joined.

below code i tried, but not working

 

(defun c:JoinCurvesBetweenPoints ( / pt1 pt2 ss i ent objList)
;; Prompt for the first point
(setq pt1 (getpoint "\nSpecify first point: "))
;; Prompt for the second point
(setq pt2 (getpoint "\nSpecify second point: "))

;; Select objects between the two points
(setq ss (ssget "C" pt1 pt2))

;; Check if any objects were selected
(command "_.pedit" ss "J" "y" "J")
(princ)
)

 

Tags (2)
Labels (1)
33 REPLIES 33
Message 2 of 34

What if you change this line:

(setq ss (ssget "C" pt1 pt2))

 to this line:

(setq ss (ssget "_F" (list pt1 pt2) '((0 . "*POLYLINE,LINE"))))

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 3 of 34

Also try changing this line:

(command "_.pedit" ss "J" "y" "J")

to this line;

(command "-pedit" "_M" ss "" "_J" "_Y" "_J")

Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 4 of 34

What is your typical setting for the PEDITACCEPT System Variable?  That will have an effect.

Kent Cooper, AIA
Message 5 of 34
Kent1Cooper
in reply to: paullimapa


@paullimapa wrote:

.... to this line:

(setq ss (ssget "_F" (list pt1 pt2) '((0 . "*POLYLINE,LINE"))))

(setq ss (ssget "_F" (list pt1 pt2) '((0 . "*POLYLINE,LINE,ARC"))))

But even then, depending on the specifics, there could easily be things that a Crossing-window selection would find that a Fence selection between just the two points would not find.  And there could be qualifying things that don't relate to each other in a joinable way.

@arunkumar_selvarajan , can you post a small sample drawing with a few situations of the kind you would use this for?

 

And also, Never say only "not working"!

Kent Cooper, AIA
Message 6 of 34

You can also troubleshoot this yourself by copy and pasting a line of code at a time onto the command prompt and see how AutoCAD responds:

(setq pt1 (getpoint "\nSpecify first point: "))
(setq pt2 (getpoint "\nSpecify second point: "))
(setq ss (ssget "C" pt1 pt2))

then enter the Pedit command directly at the command prompt followed by the values used in your code:

(command "_.pedit" ss "J" "y" "J")

To recall the ss variable on the command prompt precede it with an exclamation mark like this:

!ss

Let us know what errors you receive 

Also as @Kent1Cooper posted the Pedit response would be different depending on your current PeditAccept setting whether 0 or 1 so you can change this setting prior to entering the Pedit command


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 7 of 34

@Kent1Cooper & @paullimapa 

Thanks for the reply,

I tried your methods, and updated the code, I'm getting the below error
Command: JOINCURVESBETWEENPOINTS
Specify first point:
Specify second point: Unknown command "-PEDIT". Press F1 for help.
Unknown command "M". Press F1 for help.
<Selection set: 65>

actually, the above Lisp program which I had given is a part of my program, in which dish ends needs to be created for OD and thickness given, the curves are getting generated correctly, i want to join the curves and offset to thickness value.

I'm struck in the joining and offset.

Message 8 of 34

please share your updated code and share a sample drawing 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 9 of 34

@paullimapa 

Attached my master code and  drawing, in that LISP code line no 82 for top dish, it is working, but for bottom I'm not getting, so checking alternate methods.

 

 

(defun c:JoinCurvesBetweenPoints ( / pt1 pt2 ss i ent objList)
;; Prompt for the first point
(setq pt1 (getpoint "\nSpecify first point: "))
;; Prompt for the second point
(setq pt2 (getpoint "\nSpecify second point: "))

;; Select objects between the two points
(setq ss (ssget "_F" (list pt1 pt2) '((0 . "*POLYLINE,LINE,ARC"))))

;; Check if any objects were selected
(command "_.pedit" "_M" ss "" "_J" "_Y" "_J")
(princ)
)

;; This line is required to load the function automatically when the Lisp file is loaded
(princ "\nType JoinCurvesBetweenPoints to run the function.\n")

above is the updated code for joining.

 

 

Message 10 of 34

When I run your revised c:JoinCurvesBetweenPoints one line at a time as I suggested for troubleshooting this is what I end up seeing at the commandline in the middle of the PEDIT command [my PEDITACCEPT value is 0]

So I don't see how you would be getting a different error:  'Unknown command "-PEDIT".'

paullimapa_0-1722235097522.png

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 11 of 34

@paullimapa 
as per your previous suggestion 

(command "-pedit" "_M" ss "" "_J" "_Y" "_J")

 

for the above line i got that error then, i have updated to (command "_.pedit" "_M" ss "" "_J" "_Y" "_J")
so, the unknow command error doesn't occur. But still the join operation didn't happen.

also if u see my pervious attached lisp program "Test_Lisp" in that i have done an operation in line 82, which doesnt happen for my below dish.

Message 12 of 34

ok, that was my mistake. not -pedit but should be _pedit.

now reviewing your 82 line:

(command "pedit" pt2 "" "j" "c" pt1 (list (car pt11)(cadr pt7)) "" "")

If I compare that to typing it in with pt2 as a getpoint on the pline (not the arcs) then the sequence of commands look like this:

paullimapa_0-1722237078640.png

which means the code would look like this:

(command "_.pedit" pt2 "j" "c" pt1 (list (car pt11)(cadr pt7)) "" "")

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 13 of 34

and how many which curves are supposed to be in between those points?

Message 14 of 34
paullimapa
in reply to: komondormrex

well, I'm just looking at your bottom dish....assuming those coordinates are similar to this:

paullimapa_0-1722240094244.png

then the two arcs at each end should be joined to the middle pline segment to become a single pline

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 15 of 34

Yes, somewhat it is correct @paullimapa , so that it should select all the 5 curves as shown below.

 

arunkumar_selvarajan_0-1722240342134.png

or it can be other way as shown below

arunkumar_selvarajan_0-1722240532842.png

 

Message 16 of 34

So you just have to make sure your code gives the right points to select all the curves to join as a single Pline


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 17 of 34

Hi,
as shown in the below replies, it would be around 5 Curves.
Message 18 of 34

@paullimapa 

 

please find the updated code, if i run each line individually, it works, but when i run as a full program its not working.

 

attached the updated code.

Message 19 of 34

How about something that asks you to pick any part of what you want to join, and then uses PEDIT/Join/ALL to join everything that can be joined to the one you select, whichever it is?  No need for two points.

Kent Cooper, AIA
Message 20 of 34

Hi @Kent1Cooper ,

 

I have attached my full code in my pervious reply (Test_Lisp), in that you can see in line 82 i would perform the join operation, same I should be getting for the bottom dish in line 100.

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Forma Design Contest


Autodesk Design & Make Report