Results 1 to 5 of 5

Thread: can we combine in one command

  1. #1
    Member
    Join Date
    2009-09
    Posts
    2
    Login to Give a bone
    0

    Default can we combine in one command

    this is 2 lisp
    can we combine in one command

    Code:
    (defun c:22SelectsBlockLayer0 ( / idx lst sel )(if (setq sel (ssget '((0 . ""INSERT""))))(repeat (setq idx (sslength sel))(block->0 (cdr (assoc 2 (entget (ssname sel (setq idx (1- idx)))))))))(command ""_.regen"")(princ))(defun block->0 ( blk / ent enx )(cond( (member blk lst))( (setq ent (tblobjname ""block"" blk))(while (setq ent (entnext ent))(entmod (subst-append 8 ""0"" (subst-append 62 256 (setq enx (entget ent)))))(if (= ""INSERT"" (cdr (assoc 0 enx)))(block->0 (cdr (assoc 2 enx)))))(setq lst (cons blk lst)))))(defun subst-append ( key val lst / itm )(if (setq itm (assoc key lst))(subst (cons key val) itm lst)(append lst (list (cons key val)))))
    "
    
    
    (defun c:22SelectsBlockAllByBlock (/ *error* adoc lst_layer func_restore-layers)
    
     (defun *error* (msg)
       (func_restore-layers)
       (vla-endundomark adoc)
       (princ msg)
       (princ)
       ) ;_ end of defun
    
     (defun func_restore-layers ()
       (foreach item lst_layer
         (vla-put-lock (car item) (cdr (assoc ""lock"" (cdr item))))
         (vl-catch-all-apply
           '(lambda ()?
              (vla-put-freeze
                (car item)
                (cdr (assoc ""freeze"" (cdr item)))
                ) ;_ end of vla-put-freeze
              ) ;_ end of lambda
           ) ;_ end of vl-catch-all-apply
         ) ;_ end of foreach
       ) ;_ end of defun
    
     (vl-load-com)
     (vla-startundomark
       (setq adoc (vla-get-activedocument (vlax-get-acad-object)))
       ) ;_ end of vla-startundomark
     (if (and (not (vl-catch-all-error-p
                     (setq selset
                            (vl-catch-all-apply
                              (function
                                (lambda ()
                                  (ssget '((0 . ""INSERT"")))
                                  ) ;_ end of lambda
                                ) ;_ end of function
                              ) ;_ end of vl-catch-all-apply
                           ) ;_ end of setq
                     ) ;_ end of vl-catch-all-error-p
                   ) ;_ end of not
              selset
              ) ;_ end of and
       (progn
         (vlax-for item (vla-get-layers adoc)
           (setq
             lst_layer (cons (list item
                                   (cons ""lock"" (vla-get-lock item))
                                   (cons ""freeze"" (vla-get-freeze item))
                                   ) ;_ end of list
                             lst_layer
                             ) ;_ end of cons
             ) ;_ end of setq
           (vla-put-lock item :vlax-false)
           (vl-catch-all-apply
             '(lambda () (vla-put-freeze item :vlax-false))
             ) ;_ end of vl-catch-all-apply
           ) ;_ end of vlax-for
         (foreach blk_def
                  (mapcar
                    (function
                      (lambda (x)
                        (vla-item (vla-get-blocks adoc) x)
                        ) ;_ end of lambda
                      ) ;_ end of function
                    ((lambda (/ res)
                       (foreach item (mapcar
                                       (function
                                         (lambda (x)
                                           (vla-get-name
                                             (vlax-ename->vla-object x)
                                             ) ;_ end of vla-get-name
                                           ) ;_ end of lambda
                                         ) ;_ end of function
                                       ((lambda (/ tab item)
                                          (repeat (setq tab  nil
                                                        item (sslength selset)
                                                        ) ;_ end setq
                                            (setq
                                              tab
                                               (cons
                                                 (ssname selset
                                                         (setq item (1- item))
                                                         ) ;_ end of ssname
                                                 tab
                                                 ) ;_ end of cons
                                              ) ;_ end of setq
                                            ) ;_ end of repeat
                                          tab
                                          ) ;_ end of lambda
                                        )
                                       ) ;_ end of mapcar
                         (if (not (member item res))
                           (setq res (cons item res))
                           ) ;_ end of if
                         ) ;_ end of foreach
                       (reverse res)
                       ) ;_ end of lambda
                     )
                    ) ;_ end of mapcar
           (vlax-for ent blk_def
             (vla-put-layer ent ""0"")
             (vla-put-color ent 0)
             (vla-put-lineweight ent aclnwtbyblock)
             (vla-put-linetype ent ""byblock"")
             ) ;_ end of vlax-for
           ) ;_ end of foreach
         (func_restore-layers)
         (vla-regen adoc acallviewports)
         ) ;_ end of progn
       ) ;_ end of if
     (vla-endundomark adoc)
     (princ)
     ) ;_ end of defun"
    Last edited by rkmcswain; 2019-04-08 at 01:38 PM. Reason: Added [CODE] tags

  2. #2
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL USA
    Posts
    3,658
    Login to Give a bone
    0

    Default Re: can we combine in one command

    You need to edit your post and Wrap Code tags around the code.

    Clicking the [Go Advanced] button at the bottom puts a toolbar at the top and the # icon in that toolbar places code tags around selected text for you or simply paste your code inside.

  3. #3
    AUGI Addict madcadder's Avatar
    Join Date
    2000-11
    Location
    Too far from the beach
    Posts
    1,054
    Login to Give a bone
    0

    Default Re: can we combine in one command

    Are you just wanting them to run back to back?

    Is it as easy as?

    Create a new command at the top (Defun C:Runboth () (22SelectsBlockLayer0) (22SelectsBlockAllByBlock))

    Removing the "C:" from both routines

    Call it done...

    (It's usually never that easy)

  4. #4
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL USA
    Posts
    3,658
    Login to Give a bone
    0

    Default Re: can we combine in one command

    Actually there's four routines up there 22SelectsBlockLayer0, block->0, subst-append, and 22SelectsBlockAllByBlock.
    block->0 has badly mismatched parentheses and subst-append has a single double-quote at the end.

    Until sadikozer34 responds explaining what he wants the code to do and posts it correctly not much we can do.

    When posting code it's best to post the link where you found it as it's the best source of information about the code as well as paying respect to it's author.

  5. #5
    Administrator rkmcswain's Avatar
    Join Date
    2004-09
    Location
    Earth
    Posts
    9,803
    Login to Give a bone
    0

    Default Re: can we combine in one command

    Quote Originally Posted by Tom Beauford View Post
    When posting code it's best to post the link where you found it as it's the best source of information about the code as well as paying respect to it's author.
    A lot of it came from here: https://www.cadtutor.net/forum/topic...s#comment-8758
    R.K. McSwain | CAD Panacea |

Similar Threads

  1. 2014: Convert and Combine
    By neorider99519183 in forum Inventor - General
    Replies: 1
    Last Post: 2014-04-03, 02:55 PM
  2. Combine
    By Loc in forum AutoLISP
    Replies: 2
    Last Post: 2009-11-04, 06:15 PM
  3. combine different sheets to one dwg?
    By eveofdestruction in forum AutoCAD General
    Replies: 2
    Last Post: 2009-09-28, 06:38 PM
  4. combine mtext
    By dion.99596 in forum AutoCAD Customization
    Replies: 2
    Last Post: 2008-01-29, 04:48 PM
  5. Can I combine .pan files into an AVI?
    By Max Lloyd in forum Revit Architecture - General
    Replies: 0
    Last Post: 2005-03-03, 11:24 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •