Setting and using the command measure as a variable

Setting and using the command measure as a variable

sgutierrezLK2GY
Participant Participant
684 Views
7 Replies
Message 1 of 8

Setting and using the command measure as a variable

sgutierrezLK2GY
Participant
Participant

Hello

 

I am new to the Lisp feature in AutoCAD. but I was wondering how can I set a variable to equal the measure function between two lines. 

 

Then divide that variable in 2 and then create an offset of one of the lines at that distances or value.

 

Example:

take this value, devide it by 2

sgutierrezLK2GY_0-1704898124161.png

 

and the new value set it as offset value and create an offset in the middle of both lines.

so the end result looks like this 

sgutierrezLK2GY_1-1704898214546.png

 

0 Likes
685 Views
7 Replies
  • Lisp
Replies (7)
Message 2 of 8

cadffm
Consultant
Consultant

Hi,

 

sorry to say, but my opinion is you have to learn the basics first.

how to math, how to get data and then you can start with simple tasks.

https://help.autodesk.com/view/OARX/2024/ENU/?guid=GUID-C64046FA-CD9E-4B38-9967-A501119E4A62

https://www.afralisp.net/autolisp/tutorials/index.php?category_id=1

 

SETQ GETPOINT GETDIST DISTANCE CAR ENTSEL and a lot more functions..

 

 

! For this goal, you don't need Lisp*, but you can use it..

AND: You will find a lot of ready codes to offset to the half distance.

 

 

 

 
 

 

 

Sebastian

Message 3 of 8

sgutierrezLK2GY
Participant
Participant

Hello, 

then you are telling me that the solution is very simples. as long as you know the basics??
also thank you for the links, have been struggling to find these kind of information 😄 

 

 

0 Likes
Message 4 of 8

ВeekeeCZ
Consultant
Consultant

Here's the motivation for you. 

 

(vl-load-com)

(defun c:midset ( / e p r)

  (if (and (setq e (entsel "\nSelect line to offset: "))
	   (setq p (vlax-curve-getclosestpointto (car e) (cadr e)))
	   (setq r (entsel "\nSelect reference line: "))
	   (setq r (vlax-curve-getclosestpointto (car r) (cadr r)))
	   (setvar 'offsetdist (/ (distance p r) 2))
	   )
    (command "_.offset" "" e "_non" r ""))
  (princ)
  )

 

Agreed with @cadffm , learn a few basic functions and you can make wonders.

Message 5 of 8

cadffm
Consultant
Consultant

@sgutierrezLK2GY  schrieb:

then you are telling me that the solution is very simples. as long as you know the basics??

hmm. If you don't want a fully rebuilt of the native offset command, and if you just want to controle the native offset command, then yes.

 

Without Lisp (or just using a simple (command statement), you can create a macro like this:

start COMMAND OFFSET

use THROUGH option

select the object to offset

start object selection method m2p

start object selection _nea

use @ for the last point

start object selection _per

and select the other object

exit offset command

well done.

 

Sample: ^C^C^C_.OFFSET;_through;\_m2p;_nea;@;_per;\;

sure, by Lisp you can do the same, a bit more "bullet proof"


also thank you for the links, have been struggling to find these kind of information

Here is the Lisp board (it's for questions about programming tips & tricks) : Click!

 


 

Sebastian

Message 6 of 8

paullimapa
Mentor
Mentor

For this simple procedure you can use the built in AutoCAD object snap M2P aka Mid Between 2 Points


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

paullimapa
Mentor
Mentor

try this after you enter the Offset command at the command prompt:

(/(getdist"\nEnter Measurement To Be Divided By 2")2)

Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 8 of 8

Kent1Cooper
Consultant
Consultant

@cadffm wrote:

.... AND: You will find a lot of ready codes to offset to the half distance.


There are whole topics on the subject, some with multiple approaches and variants, such as >this<.

Kent Cooper, AIA
0 Likes