Jump to content

Three question (Multiple entlast, preview and i dont know what it's call)


Recommended Posts

Posted (edited)

Hello all. I hope everyone is fine.

1. Is it possible to create multiple entlast?

2. How do i make a "preview" (?) of lines, pline etc before i pick a point? Like copy, there's a secondary object right before i pick a point.

3. Let say i made a circle, and when i pressed '+' it will increse the diameter OR if i press '-' it will decrease. Maybe something that can be use beside circle.

If you can, please comment using autolisp not in VL ( im new and still learning). Thank you for your time.

Edited by Sheep
Posted (edited)
  1. I don't understand this one.
  2. In a simple way, it's not possible. In more advanced ways by using LM:GrSnap, it links to the third question you asked. 
  3. This utilises a function in AutoLISP known as grread. It basically reads any input AutoCAD receives. Combining grread with the while loop, you can enhance this feature. I think it might be too hard for you to understand this, but you can have a look at some examples.

 

Below is my example of a circle that will move alongside your circle, while pressing + and - will modify its radius.

 

(defun c:tc ( / cir gr grp grv inc rad)
    (setq cir (entmakex '((0 . "CIRCLE") (10 0.0 0.0 0.0) (40 . 10)))
	  rad 10
	  inc 1	; I'll use this as example to indicate the amount of radius it will increase and decrease with every press
	  )
    (while
	(progn
	    (setq gr (grread t 15 0)	; returns any input received by AutoCAD (at that instant moment [I think?])
		  grp (cadr gr)		; the value associated with the input (can vary)
		  grv (car gr)		; the type of input AutoCAD received
		  )
	    (cond
		((= grv 5)	; a value of 5 indicates mouse movement (and 'grp' would then be the coordinates of the cursor in UCS)
		 (entmod	; so everytime your mouse moves, you modify its center point to the mouse cursor.
		     (subst
			 (cons 10 grp)
			 (assoc 10 (entget cir))
			 (entget cir)
			 )
		     )
		 )
		((= grv 2)	; a value of 2 indicates keyboard input (and 'grp' will be an integer representing the code returned by (ascii)... (ascii "+") --> 43
		 (cond
		     ((= grp 45)	; <-- This is if the "-" key is pressed
		      (if
			  (or	; if the user presses "-" when the radius is 1, that's invalid, so include this check
			      (minusp (- rad inc))
			      (zerop (- rad inc))
			      )
			  (princ "\nRadius cannot be set smaller")
			  (entmod	; otherwise, modify the radius to decrease by 1
			      (subst
				  (cons 40 (setq rad (- rad inc)))
				  (assoc 40 (entget cir))
				  (entget cir)
				  )
			      )
			  )
		      )
		     ((member grp '(43 61))	; This is if the "+" key is pressed... In your keyboard, you may see it as "+", but what you're really pressing is "=", thus 61.
		      (entmod	; modify the radius to increase by 1
			  (subst
			      (cons 40 (setq rad (+ rad inc)))
			      (assoc 40 (entget cir))
			      (entget cir)
			      )
			  )
		      )
		     )
		 )
		((= grv 3)	; a value of 3 indicates a mouse click. You'd want to end the command when this happens
		 nil		; so include 'nil' to escape the while loop
		 )
		(t)		; Anything else, return T to stay within the loop and repeat.
		)
	    )
	)
    (princ)
    )

 

If you can use it, you can utilise it to do all sorts of cool things. Some examples are Limited Length PolylineAlign Text to CurveTracePoly

 

Plus, what's wrong with vl? You can't do many things that vl offers... like extracting block attributes, getting dynamic block properties...

Edited by Jonathan Handojo
  • Thanks 1
Posted
58 minutes ago, Jonathan Handojo said:
  1.  

 


(defun c:tc ( / cir gr grp grv inc rad)
    (setq cir (entmakex '((0 . "CIRCLE") (10 0.0 0.0 0.0) (40 . 10)))
	  rad 10
	  inc 1	; I'll use this as example to indicate the amount of radius it will increase and decrease with every press
	  )
    (while
	(progn
	    (setq gr (grread t 15 0)	; returns any input received by AutoCAD (at that instant moment [I think?])
		  grp (cadr gr)		; the value associated with the input (can vary)
		  grv (car gr)		; the type of input AutoCAD received
		  )
	    (cond
		((= grv 5)	; a value of 5 indicates mouse movement (and 'grp' would then be the coordinates of the cursor in UCS)
		 (entmod	; so everytime your mouse moves, you modify its center point to the mouse cursor.
		     (subst
			 (cons 10 grp)
			 (assoc 10 (entget cir))
			 (entget cir)
			 )
		     )
		 )
		((= grv 2)	; a value of 2 indicates keyboard input (and 'grp' will be an integer representing the code returned by (ascii)... (ascii "+") --> 43
		 (cond
		     ((= grp 45)	; <-- This is if the "-" key is pressed
		      (if
			  (or	; if the user presses "-" when the radius is 1, that's invalid, so include this check
			      (minusp (- rad inc))
			      (zerop (- rad inc))
			      )
			  (princ "\nRadius cannot be set smaller")
			  (entmod	; otherwise, modify the radius to decrease by 1
			      (subst
				  (cons 40 (setq rad (- rad inc)))
				  (assoc 40 (entget cir))
				  (entget cir)
				  )
			      )
			  )
		      )
		     ((member grp '(43 61))	; This is if the "+" key is pressed... In your keyboard, you may see it as "+", but what you're really pressing is "=", thus 61.
		      (entmod	; modify the radius to increase by 1
			  (subst
			      (cons 40 (setq rad (+ rad inc)))
			      (assoc 40 (entget cir))
			      (entget cir)
			      )
			  )
		      )
		     )
		 )
		((= grv 3)	; a value of 3 indicates a mouse click. You'd want to end the command when this happens
		 nil		; so include 'nil' to escape the while loop
		 )
		(t)		; Anything else, return T to stay within the loop and repeat.
		)
	    )
	)
    (princ)
    )

 

 

Plus, what's wrong with vl? You can't do many things that vl offers... like extracting block attributes, getting dynamic block properties...

Nothing is wrong with VL. Im new to autolisp even at the most basic level. I need to understand autolisp before moving to VL.

For the first question, is it possible to make multiple entlast so i dont have to immediately call it.  For example i made a circle (entlast) but later on i would like to merge the circle with a new entlast after a different set of calculation is done. 

I assume LM:Grsnap referring to Lee Mac right? I'll check that later today. Thank you for your response.

Posted

Yes, it refers to Lee Mac. With grread, you can't actually snap your cursor to any of the OSMODEs. Which is why Lee created that function to enhance grread, and I create GrPolar in that TracePoly link.

 

I mean you can always do:

 

(defun c:test ( / lst rtn)
    (setq lst (entlast) rtn (list lst))
    
    ;; do your thing here
    
    (while (setq lst (entnext lst))
	(setq rtn (cons lst rtn))
	)
    )

 

  • Like 1
Posted

If you want a selection set can do in a couple of ways ssadd the entlast or make a list using cons of the entity names.

 

(ssadd [<ENAME>][<SS>])

Adds entities to selections sets.

 

(setq ss (cons (entlast) ss)

 

Dynamic radius maybe +5 -10 +23.45 look at the two parts - + and the xxxx, + - on own uses default inc. Use getstring input. 

 

Another using grips 'cal  (rad + 10)

 

 

  • Thanks 1

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