Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 11/12/2025 in Posts

  1. Case 1: ssadd does a check if the entity exists in the set, you can change CASE 1 (setq ss (ssadd)) (if (not (ssmemb n ss)) (ssadd n ss) ;code );if to CASE 1 (ssadd n ss) ;code Often in code optimisation is rarely a single line that makes a difference... unless you are doing thousands of calculations, so here taking out an if statement won't do a lot. Most likely you have a loop within a loop that slows things - might be more efficient to look back at how you are selecting the entities and processing them before adding to the selection set. However don't just accept that, if you code will work without the line take out your if statement, and ssadd and you shouldn't really notice a big difference in speed
    1 point
  2. They are either on a locked layer. have an error msg saying # number entitys on locked layer can't move. or inside a block or xref. (setq ss (ssget "WP" Co-ord)) ; Select all entities in window polygon (setq lock (ssget "WP:L" Co-ord)) ; Select entities not on locked layers (setq n (- (sslength ss) (sslength lock))) ; Calculate difference (if (> n 0) ; if n is greater than 0 display msg (prompt (strcat "\n" (itoa n) " entities on a locked layer")) )
    1 point
  3. Another... https://forums.augi.com/showthread.php?170434-MText-width-set-to-zero&s=8d83700e43971c18c05d195f56cd176a&p=1330953&viewfull=1#post1330953
    1 point
  4. Here's my non-VL method by pure maths: (defun c:chf ( / dis getline ins len ln1 ln2 p1 p11 p12 p2 p21 p22) (defun getline (msg / ln) (while (progn (setvar 'errno 0) (setq ln (car (entsel msg))) (cond ((= (getvar 'errno) 7) (princ "\nNothing selected")) ((null ln) nil) ((not (eq (cdr (assoc 0 (entget ln))) "LINE")) (princ "\nObject is not a line")) ) ) ) ln ) (setq ln1 (getline "\nSelect first line: ") ln2 (getline "\nSelect second line: ") dis (getdist "\nSpecify line length: ") p11 (cdr (assoc 10 (entget ln1))) p12 (cdr (assoc 11 (entget ln1))) p21 (cdr (assoc 10 (entget ln2))) p22 (cdr (assoc 11 (entget ln2))) ins (inters p11 p12 p21 p22 nil) ) (if ins (mapcar '(lambda (x y / len p1 p2) (if (and (not (equal x ins 1e-8)) (not (equal y ins 1e-8)) ) (progn (setq len (/ dis (sqrt (* 2 (- 1 (cos (JH:InnerAngle x ins y)))))) ; <-- cosine rule p1 (polar ins (angle ins x) len) p2 (polar ins (angle ins y) len) ) (entmake (list '(0 . "LINE") (cons 10 p1) (cons 11 p2))) ) ) ) (list p11 p12 p11 p12) (list p21 p22 p22 p21) ) ) (princ) ) ;; JH:InnerAngle --> Jonathan Handojo ;; Returns the smaller angle between three point p1 p2 p3 ;; with p2 as the pivot, in radians. (defun JH:InnerAngle (p1 p2 p3 / 2p ang) (setq ang (- (angle p2 p3) (angle p2 p1)) 2p (+ pi pi)) (while (not (<= 0 ang 2p)) (if (< ang 0) (setq ang (+ ang 2p)) (setq ang (- ang 2p)))) (if (> ang pi) (- 2p ang) ang) )
    1 point
×
×
  • Create New...