- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have to make a routine to duplicate a series of blocks that need to be selected to make a copy of them. in this case, it is an electrical diagram, where the work is carried out on a series of blocks in a row on the X axis. In practice, the drawing that will be obtained is a row of drawn sheets where the main block is called "foglio_schema_dinamico". the insertion point of the first block (the foglio_schema_dinamico) is x=0 and Y=0. the pitch for the other blocks (the same as the first one) is 294 on the X axis so the second sheet will have the insertion point X=294 and Y=0, the third will have x= 588 and Y=0 and so on. The routine, when activated by a command or button, must:
- select the block insertion point "foglio_schema_dinamico" with the highest X value (i.e. the last in the row;
- ask to select any other objects;
- finish the selection with a send command;
- ask how many lengths (the 294) the second point (where the selected objects will be glued) should be
- exit the command.
Be careful, you must not make multiple copies, but only paste at X distances multiples of 294. In practice I must:
- copy other objects beyond the "foglio_schema_dinamico" block;
- being able to enter the number that must be multiplied by 294 which defines the glue point, therefore, 294, 588, 882 and so on;
- exit the command
I wrote this but it goes into error and I can't fix it, it always reports the error
AGGIUNGI_FOGLIO
Select the insertion point for the new block:
Selected insertion point: X=3016.56, Y=448.07; Error: Incorrect Dot Argument
Command:
(defun C:AGGIUNGI_FOGLIO ()
(setq insertion-point (getpoint "\nSeleziona il punto di inserzione per il nuovo blocco: "))
(if (and insertion-point (listp insertion-point))
(progn
(setq x-last (car insertion-point))
(setq y-last (cadr insertion-point))
(princ (strcat "\nPunto di inserzione selezionato: X=" (rtos x-last 2 2) ", Y=" (rtos y-last 2 2)))
(setq objects (ssget "\nSeleziona gli oggetti da copiare: "))
(if objects
(progn
(princ "\nOggetti selezionati correttamente.")
(setq num-lengths (getint "\nInserisci il numero di lunghezze (multipli di 294): "))
(setq x-offset (* num-lengths 294))
(princ (strcat "\nOffset calcolato: " (rtos x-offset 2 2)))
(setq new-point (list (+ x-last x-offset) y-last))
(princ (strcat "\nNuovo punto di inserzione: X=" (rtos (car new-point) 2 2) ", Y=" (rtos (cadr new-point) 2 2)))
;; Utilizza il comando "_COPY" per evitare problemi di localizzazione
(command "_COPY" objects "" (list x-last y-last) (list (+ x-last x-offset) y-last))
(princ "\nOperazione completata.")
)
(princ "\nNessun oggetto selezionato.")
)
)
(princ "\nErrore: selezione del punto di inserzione non valida.")
)
(princ)
)
I'm starting now with autolisp, can someone help me please? Thank you all
Solved! Go to Solution.