Jump to content

insert and explode block lisp Help


Guest

Recommended Posts

I use this lisp to insert blocks

 

I have two questions

 

A)

 

(defun c:textblock ()
(COMMAND "_layer" "_m" "text" "_c" "140" "" "")
(setq scl (getvar "useri1"))
(setq scl1 (* scl 1.5))
(setq dt1 (getpoint "\ninsert text block: "))
(command" "*insert" "textblock" dt1 scl1 scl1 "0" )
(princ)
)

 

when the block insert to the drawing exlode but have a rotation

 

I am using tis Units : Decimal,meters ,grads,Direction north.

 

The drawing temlate and the block have the same settings in the units. I dont know why .

 

When iuse the same lisp without "*" i have no rotation problem but not exlope.

 

B) Second question

 

I have this lisp to insert a drawing stamp (Rtext)

 

(defun c:dstamp ()
(COMMAND "_layer" "_m" "dstamp" "_c" "140" "" "")
(setq scl (getvar "useri1"))
(setq scl1 (* scl 1.5))
(setq dt1 (getpoint "\ninsert dstamp: "))
(command"insert" "dstamp" dt1 scl1 scl1 "0" )
(princ)
)

 

I whant after insert to explode the Rtext 2 times to convert it to simple text

 

Thanks

Link to comment
Share on other sites

Try

 

(defun c:textblock ( / DT1 SCL SCL1)
(COMMAND "_layer" "_m" "text" "_c" "140" "" "")
(setq scl (getvar "useri1"))
(setq scl1 (* scl 1.5))
(setq dt1 (getpoint "\ninsert text block: "))
(command "insert" "*textblock" dt1 scl1 "0" )
(princ)
)
(defun c:dstamp ( / DT1 SCL SCL1)
(COMMAND "_layer" "_m" "dstamp" "_c" "140" "" "")
(setq scl (getvar "useri1"))
(setq scl1 (* scl 1.5))
(setq dt1 (getpoint "\ninsert dstamp: "))
(command "insert" "*dstamp" dt1 scl1 "0"
 "_.explode" "_L"
 "_.explode" "_L")
(princ)
)

 

HTH

Henrique

Link to comment
Share on other sites

You're welcome, prodromosm

 

(defun c:dstamp ( / DT1 SCL SCL1)
(COMMAND "_layer" "_m" "dstamp" "_c" "140" "" "")
(setq scl (getvar "useri1"))
(setq scl1 (* scl 1.5))
(setq dt1 (getpoint "\ninsert dstamp: "))
(command "insert" "dstamp" dt1 scl1 scl1 "0")
(command "_.explode" "_L")
(initcommandversion)
(command "_.explode" "_P" "")
(initcommandversion)
(command "_.explode" "_P" "")
(princ)
)

 

HTH

Henrique

Link to comment
Share on other sites

other variant.

Use Inserting Exploded Blocks

Preceding the name of the block with an asterisk (*) explodes the block and inserts the individual parts of it. The block definition is not added to the drawing

and QAFLAGS=5

does not depend on the amount of Rtext in the block.

(defun c:dstamp ( / DT1 SCL SCL1 SS *error* qf)
 (defun *error* ( msg )
   (and qf (setvar 'QAFLAGS qf))
   (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
       (princ (strcat "\n** Error: " msg " **")))
   (princ)
 )

(COMMAND "_layer" "_m" "dstamp" "_c" "140" "" "")
(setq scl (getvar "useri1"))
(setq scl1 (* scl 1.5))
(setq dt1 (getpoint "\ninsert dstamp: "))
(mip:mark)  
(command "_-insert" "*dstamp" dt1 scl1 scl1)
(if (setq SS (mip:get-last-ss))
 (progn
     (setq qf (getvar 'QAFLAGS))
     (setvar 'QAFLAGS 5)

     (command "_.explode" ss "")

     (setvar 'QAFLAGS qf)
   )
)
 
)

;;;* Mark data base to allow KB:catch.
;;;* http://www.theswamp.org/index.php?topic=15863.0
(defun mip:mark ( )
(if (setq *mip:mark (entlast)) nil
   (progn (entmake '((0 . "point") (10 0.0 0.0 0.0)))
      (setq *mip:mark (entlast))(entdel *mip:mark)))(princ))
;;;* returns selection set of entities since last mip:mark.
(defun mip:get-last-ss (/ ss tmp val)
 (setq val (getvar "cmdecho"))
 (setvar "cmdecho" 0)
 (if *mip:mark
   (progn (setq ss (ssadd))
          (while (setq *mip:mark (entnext *mip:mark))
            (ssadd *mip:mark ss)
          ) ;_ end of while
          (if (> (sslength ss) 0)
            (progn
              (command "_.select" ss "")
              (setq tmp ss)
            ) ;_ end of progn
            (setq tmp nil)
          ) ;_ end of if
   ) ;_progn
   (alert
     "*mip:mark not set. \n run (mip:mark) before mip:get-last-ss."
   ) ;_ end of alert
 ) ;_if
 (setvar "cmdecho" val)
 tmp
) ;_ end of defun

Link to comment
Share on other sites

Hi VVA,

nice code.

 

 

But, you'll need to explode twice, Rtext after explode becomes Mtext and you'll nead to explode again to become Text, as OP request.

 

 

You don't need to to change QAFLAGS SysVar to explode a selection set, if you just use the initcommandversion function before the explode command, will allow a selection set as an argument.

 

Henrique

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...