Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 02/14/2024 in all areas

  1. You're right! good catch! Updated my previous post to match your solution.
    1 point
  2. Not quite 'last point' doesn't get either of the points used in the selection, the last point is the one before the selection set. This one will get the mouse pointer as reference and grab the point when you hit 'enter' at the end of the selection set selection, (defun c:qmove ( / pt1 MySS) (while (setq MySS (ssget)) (setq pt1 (cadr (grread t 15 0)) ) (command "move" MySS "" pt1 pause ) ) (princ) )
    1 point
  3. Here is a slightly slower version that allows multiple selection: (defun c:qmovem ( / p ss) (princ "\nSelect Objects: ") (While (setq ss (ssget)) (setq p (cadr (grread t 15 0)));<-- Thanks Steven P for this part! (command "._move" ss "" "_non" p pause) (princ "\nSelect Objects: ") ) (princ) ) EDIT: Updated to correct it based on Steven P feedback.
    1 point
  4. @aridzv I recommend you slightly change your code (sorry - can't help but mess with stuff): (defun c:qmv ( / ent entd bpt ) (while (setq ent (entsel "\nSelect object to move:")) ;select object to move, ENTER to exit (setq entd (entget (car ent))) (setq bpt (cdr (assoc 10 entd))) ;get the object insertion point or the first vertex of *line(s) (command "._move" ent "" "_non" bpt pause) ;move the object using bpt (the object insertion point or the first vertex of *line(s)) as base point. ) )
    1 point
  5. Not necessarily... Sometimes the user will prefer the original solution you wrote. Visually it is indeed much more comfortable. But sometimes a defined point of the object will be needed.
    1 point
  6. @aridzv Good "Point" (pardon the pun) . I agree that's a good option. I was just replicating the original function the OP liked.
    1 point
  7. That is probably best for this LISP I think
    1 point
  8. @Steven P Edited my original post to add another solution. not too much more code to make it the same and loop cleanly.
    1 point
  9. @Jamesclark64 While this is not the best programming practice, putting the command in a loop is easy; you just have to ESC to stop it. Someone else here may have a better trick without making it a much bigger program. (defun c:qmove ( / ) ;;single object selection (While T (command "._move" pause "" "_non" (getvar "lastpoint") pause) ) ) ACTUALLY - this is better programming practice and works the same without needing ESC to exit: (defun c:qmove ( / e p) ;;single object selection (While (setq e (entsel "\nSelect Object: ")) (setq p (cadr e) e (car e)) (command "._move" e "" "_non" p pause) ) (princ) )
    1 point
  10. Thanks for the details!
    1 point
  11. @vanowm I've modified the formula to handle corners that are not 90°. Here's the revised formula for theta, the bend angle. THETA = acos(tan(ALPHA) / tan(90 - BETA/2)) Here's a LISP program to calculate THETA (defun c:foldangle (/ alpha beta theta) ;; calculate fold angle lrm 2/14/2024 (setq alpha (getreal "\nEnter alpha (deg): ")) (setq beta (getreal "\nEnter beta (deg): ")) (setq theta (acos (/ (tan (/ (* alpha pi) 180)) (tan (- (/ pi 2.) (/ (* beta pi) 360))) ) ) ) (setq theta (/ (* theta 180.) pi)) (princ "\n THETA = ") (princ theta) (princ) ) ;; ArcCosine - Lee Mac ;; Args: -1 <= x <= 1 (defun acos ( x ) (if (<= -1.0 x 1.0) (atan (sqrt (- 1.0 (* x x))) x) ) ) ;; Tangent - Lee Mac ;; Args: x - real (defun tan ( x ) (if (not (equal 0.0 (cos x) 1e-10)) (/ (sin x) (cos x)) ) ) Note that in your drawing the angles for the tabs are not equal. They should be.
    1 point
  12. @Aditya Bagaskara Study these System Variables. You can look them up in AutoCAD's help bar: LUNITS = Integer representing the liner units type; i.e. Scientific, Decimal, Fractional, etc.. LUPREC = Integer representing the unit precision; i.e. how many places behind the decimal point. MEASUREMENT = 0 is Imperial (inches), and 1 is Metric (mm, cm, m) MEASUREINIT = integer representing whether imperial (0) or metric (1) Hatch patterns and Linetypes are used. There are more, but those the the main ones. Technically - AutoCAD is "scaleless", meaning you define the scale of 1 unit, whether that is 1 mm or 1 meter. The system variables above control how that scaling is displayed and calculated. In Imperial measurement however, Fractional and Architectural scale are dependant on inches being the 1 unit, because of the way they are displayed.
    1 point
  13. Sysvdlg shows you all the variables and explain what's it's use
    1 point
  14. Setvar ? * is your answer as 1st step. Press Enter Enter ........ Setvar ? T*
    1 point
  15. Given a flat pattern that looks like this. The angle theta needed to rotate each tab up about it edge so that the ends are coincident is: THETA = ACOS(TAN(ALPHA)) Which yields the following.
    1 point
  16. @Abrasive Try this. Not sure if this is what you want. I thought this was an interesting challenge. Use the plus [+] and Minus [-] keys to change the boundary size. (defun C:ZOOMD (/ _rect ac code data h ls pt v) (vl-load-com) ; Sub function for drawing the zoom boundary. (defun _rect () (mapcar '(lambda (a) (grdraw (car a) (cadr a) -1)) (list (list (car ls) (list (car (cadr ls)) (cadr (car ls)))) (list (list (car (cadr ls)) (cadr (car ls))) (cadr ls)) (list (cadr ls) (list (car (car ls)) (cadr (cadr ls)))) (list (list (car (car ls)) (cadr (cadr ls))) (car ls)) ) ) ) (setq ac (vlax-get-acad-object) h (/ (getvar "viewsize") 4.0) v (list (* h (apply '/ (getvar "screensize"))) h) ) (princ "\nUse [+] or [-] keys to Increase or Decrease Zoom Boundary and Pick Center: ") (while (not pt) (setq gr (grread t 15 0) code (car gr) data (cadr gr)) (if ls (_rect)) (cond ((= code 5) (setq ls (list (mapcar '- data v) (mapcar '+ data v))) (_rect) ) ((= code 2) (cond ((or (= data 43)(= data 61)) (setq scl 1.5 v (mapcar '(lambda (x) (* x scl)) v)) (_rect) ) ((= data 45) (setq scl 0.75 v (mapcar '(lambda (x) (* x scl)) v)) (_rect) ) ) ) ((= code 3)(setq pt T)) ) ) (vla-zoomwindow ac (vlax-3d-point (car ls)) (vlax-3d-point (cadr ls))) (princ) )
    1 point
  17. AutoLisp can access the system variables. With GETVAR you can read the values stored in INSUNITS or MEASUREINIT. Some variables also can be changed using the SETVAR command. Just find the sysvar that is relevant for your task.
    1 point
×
×
  • Create New...