Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 05/14/2025 in all areas

  1. A fairly simple task based on the smaple dwg. (defun c:numblk ( / ss num lst obj atts att1 numstr) (while (setq ss (ssget '((0 . "insert")))) (setq num (getint "\nEnter start number ")) (setq lst '()) (repeat (setq k (sslength ss)) (setq ent (entget (ssname ss (setq k (1- k))))) (setq inspt (cdr (assoc 10 ent))) (setq x (car inspt) y (cadr inspt)) (setq entname (cdr (assoc -1 ent))) (setq lst (cons (list Y X entname) lst)) ) (setq lst (vl-sort lst '(lambda (a b) (cond ((> (car a) (car b))) ((= (car a) (car b)) (< (cadr a) (cadr b))) ) ) ) ) (foreach blk LST (setq obj (vlax-ename->vla-object (caddr blk))) (setq atts (vlax-invoke obj 'Getattributes)) (setq att1 (car atts)) (cond ((< num 10)(setq numstr (strcat "00" (rtos num 2 0)))) ((< num 100)(setq numstr (strcat "0" (rtos num 2 0)))) ((setq numstr (rtos num 2 0))) ) (vlax-put att1 'textstring numstr) (setq num (1+ num)) ) ) (princ) )
    2 points
  2. @GLAVCVS I tried your program and it is very nice. Yesterday I was thinking of writing a random chord length routine but you seem to have a good solution, so now I will just study your code to see what I can learn.
    1 point
  3. This should get you most of the way there, though, it is written for text/mtext instead of attributes.
    1 point
  4. Just a real comment, re speed. Manual task do 2000+ changes = 3hrs. 1st go at a program using command = 32 minutes. About 5 go, using VL = 2 minutes. Client was very So if speed is a problem need to look at what your coding just changing to VL or entmake may give improvements, but using defuns and cond v's multi If's can increase speed also.
    1 point
  5. Review lines 1076-1112 of my TabSort program for an example of how to accomplish this using COM; though, this is one of those scenarios where a simple command call will likely perform faster, given the number of operations involved to copy the layout - such operations can be performed by the C++ implementation of the command rather than individually interpreted through evaluation of each LISP expression.
    1 point
×
×
  • Create New...