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

Stretch command through autolisp

6 REPLIES 6
Reply
Message 1 of 7
Anonymous
3345 Views, 6 Replies

Stretch command through autolisp

Hello Everybody,

I have three lines, which has common end point. Now I want to stretch these lines by taking this common end point as base point.

My logic is,

(setq ent (ssget))
(setq basep (getpoint)) ;; I will select common end point of three lines
(command "_stretch" ent basep '(15 15))

But unable to stretch all three lines to my desired location.

Please guide me.

Sumit
6 REPLIES 6
Message 2 of 7
M_Hensley
in reply to: Anonymous

Your problem is that the stretch command does not work the way you have programmed. You need to select 2 points for the corners of a crossing that include the ends of your 3 lines, then a base point and finally a second point of displacement.
Message 3 of 7
Anonymous
in reply to: Anonymous

Hi hensley,

Thanks!
I could not get "You need to select 2 points for the corners of a crossing that include the ends of your 3 lines"

Can you please tell me by creating Lisp code for the same line.

I hope I am not bothering you.

Thanks for your help.

Sumit
Message 4 of 7
Anonymous
in reply to: Anonymous

The reason you can't stretch things with a pre-defined selection set is that
the Stretch command needs to know how much of the things selected are inside
the crossing window, so it knows whether to move them completely, or change
one end, or whatever is appropriate depending on the entity type.

But in this particular case, I don't think you need Lisp at all. Just grab
the three lines by a crossing (right-to-left) window, with no Command
active, and pick on the grip at the shared endpoint, and drag it wherever
you want. It will stretch all three, the same as with a more explicit
Stretch command.

--
Kent Cooper


wrote...
Hi hensley,

Thanks!
I could not get "You need to select 2 points for the corners of a crossing
that include the ends of your 3 lines"

Can you please tell me by creating Lisp code for the same line.

I hope I am not bothering you.

Thanks for your help.

Sumit
Message 5 of 7
Anonymous
in reply to: Anonymous

Hello Kent,
Thanks for your reply.
But I wanted modify entity in one application by using stretch command.

Sumit
Message 6 of 7
Kiwi Russ.
in reply to: Anonymous

Sumit
Try this code by Richard Novara. It might be close to what you want. If not you could modify it to suit
Russ

(defun C:STRTCH (/ X Y PT1 PT2 SS SS1 SS2 A OS EN ECHO)
(setq ECHO (getvar "CMDECHO"))
(setvar "CMDECHO" 0)
(setq os (getvar "OSMODE"))
(setvar "OSMODE" 0)

(prompt "\n X Distance to Stretch: < 0 >")
(setq X (getstring))
(if (= X "")(setq X "0"))
(prompt "\n Y Distance to Stretch: < 0 > ")
(setq Y (getstring))
(if (= Y "")(setq Y "0"))
(setq A (strcat "@" X "," Y))

(setq PT1 (getpoint "\n Select Entities to Stretch by Crossing Window:"))
(prompt "\n 1st Point:")
(setq PT2 (getcorner PT1 "\n 2nd Point:"))


(prompt "\n Remove Entities..... Add Entities: ")
(command "Select" "c" PT1 PT2 pause)
(setq SS (ssget "p")) ;
(setq SS1 (ssget "c" PT1 PT2))
(setq SS2 (ssadd))
(while ( setq EN (ssname SS1 0))
(if (null (ssmemb EN SS))
(ssadd EN SS2)
);if
(ssdel EN SS1)
);while
(if (< 0 (sslength SS2))
(command "select" SS2 "" "stretch" "C" PT1 PT2 "R" "P" "" "" A)
(command "stretch" "c" PT1 PT2 PT1 "" "" A)
);if
(setvar "OSMODE" OS)
(setvar "CMDECHO" ECHO)
(princ)
);end strtch.lsp
Message 7 of 7
Anonymous
in reply to: Anonymous

Hello Kiwi Russ,

Thanks for your Help. I am beginner in Lisp so this code is bit hard to understand but I will study it. Thank you very much.

Sumit

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

Post to forums  

Autodesk Design & Make Report

”Boost