broncos15 Posted September 18, 2015 Share Posted September 18, 2015 I have a question about calling a lisp routine from within another lisp I am creating. I know from searching the forums that I can use either the (c:lisproutinename) or from looking at Lee Mac's lisp routines, using the defun LM. My difficulty is getting the my lisp routine to run the other lisp routine and fill in what the user would typically have to. I am trying to create a cleaner command and part of it would set all the block internal components to layer 0. Using a previously made lisp routine for the setting block internal components to layer 0, I have created the following but it is not working properly and I know it has to do with how I am calling the lisp: (setq sel5 (ssget "X" '((0 . "BLOCK")))) (c:blockchangeentitiestolayer0 sel5 "") Quote Link to comment Share on other sites More sharing options...
satishrajdev Posted September 18, 2015 Share Posted September 18, 2015 post your routine here which you want to use...So can check it's variables. OR try this once (command "blockchangeentitiestolayer0" sel5 "") Quote Link to comment Share on other sites More sharing options...
broncos15 Posted September 18, 2015 Author Share Posted September 18, 2015 post your routine here which you want to use...So can check it's variables. OR try this once (command "blockchangeentitiestolayer0" sel5 "") The issue with using the command function is that it doesn't work for lisp routines. Would the command function work if I included the code for changing the blocks to layer 0 as a routine before starting my new lisp routine? Quote Link to comment Share on other sites More sharing options...
Tharwat Posted September 18, 2015 Share Posted September 18, 2015 When you have a prefix C: with your program , it means that this program is to run without any arguments , and it is stand alone program . But when you need to feed any arguments , you should call it without the previous said prefix C: like this (blockchangeentitiestolayer0 sel5 ""). Quote Link to comment Share on other sites More sharing options...
satishrajdev Posted September 18, 2015 Share Posted September 18, 2015 When you have a prefix C: with your program , it means that this program is to run without any arguments , and it is stand alone program . But when you need to feed any arguments , you should call it without the previous said prefix C: like this (blockchangeentitiestolayer0 sel5 ""). I wasn't really aware of this... thankx Tharwat Quote Link to comment Share on other sites More sharing options...
Tharwat Posted September 18, 2015 Share Posted September 18, 2015 I wasn't really aware of this... thankx Tharwat You're welcome Satish. Quote Link to comment Share on other sites More sharing options...
broncos15 Posted September 18, 2015 Author Share Posted September 18, 2015 When you have a prefix C: with your program , it means that this program is to run without any arguments , and it is stand alone program . But when you need to feed any arguments , you should call it without the previous said prefix C: like this (blockchangeentitiestolayer0 sel5 ""). That is really useful to know. Thank you for the information! Quote Link to comment Share on other sites More sharing options...
Tharwat Posted September 18, 2015 Share Posted September 18, 2015 That is really useful to know. Thank you for the information! You're welcome. Did you get your routine to work afterall ? Quote Link to comment Share on other sites More sharing options...
broncos15 Posted September 18, 2015 Author Share Posted September 18, 2015 When you have a prefix C: with your program , it means that this program is to run without any arguments , and it is stand alone program . But when you need to feed any arguments , you should call it without the previous said prefix C: like this (blockchangeentitiestolayer0 sel5 ""). So I actually added this to my code, and I get error: no function definition: BLOCKCHANGEENTITIESTOLAYER0. I checked with a few other lisp routines I have loaded and they each have this error when calling them the way that you said. Thank you so much for the help by the way! Quote Link to comment Share on other sites More sharing options...
Tharwat Posted September 18, 2015 Share Posted September 18, 2015 Can you post the codes or at least the first part of the codes ? Quote Link to comment Share on other sites More sharing options...
broncos15 Posted September 18, 2015 Author Share Posted September 18, 2015 Can you post the codes or at least the first part of the codes ? So the portion of my new lisp routine is: (setq sel5 (ssget "X" '((0 . "BLOCK")))) (BLOCKCHANGEENTITIESTOLAYER0 sel5 "") The BLOCKCHANGEENTITIESTOLAYER0 works by allowing the user to select what blocks they want to change to layer 0. That's why I am trying to fill in what the user would select by adding the sel5 variable. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted September 18, 2015 Share Posted September 18, 2015 Why don't you use the command setbylayer instead ? Quote Link to comment Share on other sites More sharing options...
broncos15 Posted September 18, 2015 Author Share Posted September 18, 2015 Why don't you use the command setbylayer instead ? I just want the internal components of the block to be on layer zero, but the actual block to stay on its current layer. I'm sorry for all the questions about this. Would defining the blockchangeentitiestolayer0 as a command within the lisp such as defun:LM work better in this case, so that I could then call it using the normal (command) function? Quote Link to comment Share on other sites More sharing options...
Tharwat Posted September 18, 2015 Share Posted September 18, 2015 (setq sel5 (ssget "X" '((0 . [color=red]"BLOCK"[/color])))) The Block here is wrong because the block word is used for table block and the block objects are called block definitions and it takes the name of INSERT when it is being inserted into a drawing , so change that to INSERT to be able to select blocks. Post the codes for your function (BLOCKCHANGEENTITIESTOLAYER0) to allow me to modify it to be able to use it as per your first example. Quote Link to comment Share on other sites More sharing options...
broncos15 Posted September 18, 2015 Author Share Posted September 18, 2015 Tharwat, thank you so much for your willingness to help, and that your information about INSERT vs BLOCK is good to know. Unfortunately, The code isn't mine so I can't share it. Thanks again! Quote Link to comment Share on other sites More sharing options...
Tharwat Posted September 18, 2015 Share Posted September 18, 2015 (edited) I am happy to help . Here is an old lisp of mine and I just modified it to suit your needs and the program can change Normal / Attributed Blocks and objects as well . (defun BLOCKCHANGEENTITIESTOLAYER0 (ss / attribute b blk layer i lst name obj sn ss do) ;; Tharwat 01. June. 2012 ;; ;; This peice of code is to move all ;; ;; selected objects (Blocks / Attribted Block / Objects) to layer "0" ;; (if (not acdoc) (setq acdoc (vla-get-activedocument (vlax-get-acad-object))) ) (if (and ss (setq layer "0")) (progn (vla-startundomark acdoc) (repeat (setq i (sslength ss)) (setq obj (vlax-ename->vla-object (setq sn (ssname ss (setq i (1- i)))) ) ) (cond ((eq (cdr (assoc 66 (entget sn))) 1) (progn (if (not (member (vla-get-effectivename obj) do)) (setq do (cons (vla-get-effectivename obj) do)) ) (vlax-for block (setq b (vla-item (vla-get-blocks acdoc) (vla-get-effectivename obj) ) ) (vlax-for x b (vla-put-layer x layer)) ) (foreach attribute (vlax-invoke obj 'Getattributes) (vla-put-layer attribute layer) ) ) ) ((and (eq (cdr (assoc 0 (entget sn))) "INSERT") (not (member (vla-get-effectivename obj) lst)) ) (progn (setq lst (cons (vla-get-effectivename obj) lst)) (vlax-for block (setq blk (vla-item (vla-get-blocks acdoc) (vla-get-effectivename obj) ) ) (if (eq :vlax-false (vla-get-isXref blk)) (vlax-for x blk (if (not (eq "AcDbBlockReference" (vla-get-objectname x)) ) (vla-put-layer x layer) ) ) ) ) ) ) (t (vla-put-layer obj layer)) ) ) (if do (mapcar '(lambda (name) (vl-cmdf "_.attsync" "_name" name "") ) do ) ) (vla-regen acdoc acAllViewports) (vla-endundomark acdoc) ) (princ) ) (princ) ) (vl-load-com) To select only Normal Blocks: (BLOCKCHANGEENTITIESTOLAYER0 (ssget "_:L" '((0 . "INSERT")))) To Select only Attributed Blocks: (BLOCKCHANGEENTITIESTOLAYER0 (ssget "_:L" '((0 . "INSERT")(66 . 1)))) To select objects in general including blocks : (BLOCKCHANGEENTITIESTOLAYER0 (ssget "_:L" )) Edited September 18, 2015 by Tharwat Quote Link to comment Share on other sites More sharing options...
broncos15 Posted September 18, 2015 Author Share Posted September 18, 2015 Tharwat, thank you so much for posting that code it is super useful plus educational to look through how it all works. If I am going to use your routine as part of a larger routine that will do some other drawing cleaning, do you suggest calling it using the method you said earlier or simply using the code within my larger code set? Quote Link to comment Share on other sites More sharing options...
Tharwat Posted September 18, 2015 Share Posted September 18, 2015 do you suggest calling it using the method you said earlier or simply using the code within my larger code set? I have no idea about your codes , so I can not give you any advise in this regard and that's why I did ask you before about posting the codes and anyway it is up to you to use the one the it does help you as per your needs and requirements of course and it does not matter the method you use but the one that it helps. Good luck. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted September 18, 2015 Share Posted September 18, 2015 Sorry , I just updated the codes above and the codes written to change color and not to move objects to layer "0" , so consider the new changes. Quote Link to comment Share on other sites More sharing options...
broncos15 Posted September 18, 2015 Author Share Posted September 18, 2015 Sounds good. Thank you again for the help! Quote Link to comment Share on other sites More sharing options...
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.