See the top rated post in this thread. Click here

Results 1 to 6 of 6

Thread: Please I need help to understand how entlast works

  1. #1
    Member
    Join Date
    2020-06
    Posts
    3
    Login to Give a bone
    0

    Default Please I need help to understand how entlast works

    I have some applications to make and I don't know how to use entlast

    I have to draw 2 lines in autocad and in autolisp to make a right-angle triangle using the drawn lines to join them and automatically generate the vertical line.

    I made the code just to generate a triangle but I have no idea how to use the previously drawn lines.



    Code:
    (defun c:desen()
      (setq x (getint "x colt stanga jos"))        ;5
      (setq y (getint "y colt stanga jos"))        ;5
    
    
      (setq x1 0.0) 
      (setq y1 0.0)
      (setq pct1 (list x1 y1))
    
      (setq x2 x)
      (setq y2 0.0)
      (setq pct2 (list x2 y2)) 
    
      (setq x3 x) 
      (setq y3 y)
      (setq pct3 (list x3 y3))
      
    (entmake (list(cons 0 "polyline")))
      (entmake (list
    	     (cons 0 "vertex")
    	     (cons 10 (list x1 y1 0)))
    	   )
      (entmake (list
    	     (cons 0 "vertex")
    	     (cons 10 (list x2 y2 0)))
    	   )
      (entmake (list
    	     (cons 0 "vertex")
    	     (cons 10 (list x3 y3 0)))
    	   )
        (entmake (list
    	     (cons 0 "vertex")
    	     (cons 10 (list x1 y1 0)))
    	   )
    (entmake (list (cons 0 "SEQEND"))
      ))

  2. #2
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL USA
    Posts
    3,667
    Login to Give a bone
    0

    Default Re: Please I need help to understand how entlast works

    Welcome to our forums!
    (entlast) will always return the name of the last created entity which after entmake would be your triangle. Saving it with setq allows you to modify it later in your code if you wish.
    It's best to localize your variables with defun as in
    Code:
    (defun c:desen(/ x y x1 y1 pct1 x2 y2 pct2 x3 y3 pct3)
    You haven't added any code to draw a line yet.
    HTH

  3. #3
    Member
    Join Date
    2020-06
    Posts
    3
    Login to Give a bone
    0

    Default Re: Please I need help to understand how entlast works

    Quote Originally Posted by Tom Beauford View Post
    Welcome to our forums!
    (entlast) will always return the name of the last created entity which after entmake would be your triangle. Saving it with setq allows you to modify it later in your code if you wish.
    It's best to localize your variables with defun as in
    Code:
    (defun c:desen(/ x y x1 y1 pct1 x2 y2 pct2 x3 y3 pct3)
    You haven't added any code to draw a line yet.
    HTH
    The thing is that the lines have to be drawn in Autocad by hand and after that the autolisp code to take the line's and make the triangle with them. And I don't know how to do that.

  4. #4
    Member
    Join Date
    2020-06
    Posts
    3
    Login to Give a bone
    1

    Default Re: Please I need help to understand how entlast works

    And thank you for the warm welcome

  5. #5
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL USA
    Posts
    3,667
    Login to Give a bone
    0

    Default Re: Please I need help to understand how entlast works

    Quote Originally Posted by Jaguaro1000790336 View Post
    The thing is that the lines have to be drawn in Autocad by hand and after that the autolisp code to take the line's and make the triangle with them. And I don't know how to do that.
    Entmaking lines are easier than entmaking a polyline.
    Normally getreal would be used instead of getint to allow for input like 4.5, or using getpoint for x, y, and z at the same time.
    Enter (setq pt (getpoint)) then 4,3 returns (4.0 3.0 0.0)
    Enter (cadr pt) returns x value 3.0
    Enter (car pt) returns y value 4.0
    For user input to create a line (cons 10 pt) in your lisp returns (10 4.0 3.0 0.0) for the first point of your line.

  6. #6
    All AUGI, all the time
    Join Date
    2003-07
    Posts
    561
    Login to Give a bone
    0

    Default Re: Please I need help to understand how entlast works

    Like tom (cons 11 (list x y z)) is end point for a line

    Once created then (setq obj1 (entlast)). Make another line then (setq obj2 (entlast)) so have a record of the last 2 objects created.

Similar Threads

  1. Anybody have Entlast that works for EntmakeX?
    By tufofi in forum AutoLISP
    Replies: 3
    Last Post: 2011-09-13, 08:40 PM
  2. Help me understand this code please
    By rdogomes in forum AutoLISP
    Replies: 8
    Last Post: 2010-02-26, 04:56 PM
  3. Replies: 1
    Last Post: 2008-11-04, 05:48 PM
  4. problem with "entlast"
    By bmckenzie in forum AutoLISP
    Replies: 10
    Last Post: 2008-07-09, 06:23 PM
  5. Need help to understand spaces in routines
    By sumulong in forum AutoLISP
    Replies: 6
    Last Post: 2007-06-13, 08:37 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •