SELFCAD Posted January 19, 2012 Posted January 19, 2012 (defun C:rpb () (defun dxf (code ent) (cdr (assoc code (entget ent)))) (setvar 'Attreq 1) (setvar 'Attdia 1) (prompt "Select old blocks: ") (setq blv (ssget "_:L" '((0 . "INSERT")))) (setq bln (car (entsel "\nSelect new block: "))) ;(setq bln (getstring "\nEnter new block name: ")) (setq atr (dxf 1 bln)) (repeat (setq i (sslength blv)) (setq e (ssname blv (setq i (1- i)))) (command "_.-insert" bln (cdr (assoc 10 (entget e))) "" "" "" atr ) (command "_.erase" e "") ) ) try to replace some blocks with 1 attribute by a single block with 1 attribute...lots of mistakes..help!!! Quote
BIGAL Posted January 20, 2012 Posted January 20, 2012 This is a mess for a start you are calling a defun from within its self "dxf", defuns are used where you need to jump back and forth to them rather than just top to bottom running of a lisp. put setvars at start outside defun. It may be better to describe what your trying to do. Quote
SELFCAD Posted January 20, 2012 Author Posted January 20, 2012 I'm trying to replace 10 blocks with 1 attribute by a block with 1 attribute... but to keep the same attribute for those 10 blocks... so 10 old blocks are *block1type, 1 attrib. , and the new block is *block2type, i attrib. Quote
pBe Posted January 20, 2012 Posted January 20, 2012 Factors to consider in conjucntion with your apporach (i.e. native command insert) Insertion point = 10 (also to consider UCS) Scale = 41-43 (depending on the scale properties of the block) Rotation = 50 Layer =8 ( current to target layer) Attreq 0 Attdia 0 Osmode It would be better to create a generic routine to match by TAG/ by order / by number of tags HTH Quote
Lee Mac Posted January 20, 2012 Posted January 20, 2012 This is a mess for a start you are calling a defun from within its self "dxf", defuns are used where you need to jump back and forth to them rather than just top to bottom running of a lisp. There is nothing wrong with defining the function 'dxf' from within the function definition of 'rpb', in fact, I do this all the time to localise subfunctions to ensure their scope remains within the bounds of the main function. Consider this example: (defun c:test ( / _sub str ) (defun _sub ( msg ) (alert (strcat "This is my message to you\n\n" msg)) ) (setq str (getstring t "\nEnter a Message: ")) (_sub str) (princ) ) The function '_sub' will be defined when the function 'c:test' is evaluated, then will cease to be defined when the function 'c:test' has completed. This is beneficial for a number of reasons: from a security perspective, since the function is not accessible outside of the 'c:test' function; and I can be certain that the '_sub' symbol is using the definition I give it, since the symbol '_sub' is localised in the 'c:test' function definition. Admittedly, the OP has not localised their functions / variables. Quote
Recommended Posts
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.