shamsam1 Posted August 1, 2008 Share Posted August 1, 2008 how can i pass value from command line to lisp please guide me with sample Link to comment Share on other sites More sharing options...
vizwhiz Posted August 1, 2008 Share Posted August 1, 2008 (edited) hope This helps Edited August 2, 2008 by vizwhiz Link to comment Share on other sites More sharing options...
Peter M. Gruhn Posted August 2, 2008 Share Posted August 2, 2008 Passing parameters between functions is easy (defun bar (p1 p2) (princ(+ p1 p2)) ) (defun C:FOO () (bar 2 3) (princ) ) ----------------------------- command: foo 5 ----------------------------- Doing the same with a command function... that seems to be harder. Got an answer. Don't like it. ----------------------------- (defun C:FOO(p1 p2) (princ(+ p1 p2)) (princ) ) ----------------------------- Command: (c:foo 7 3) 10 Link to comment Share on other sites More sharing options...
shamsam1 Posted August 2, 2008 Author Share Posted August 2, 2008 this is what i like to try pumat("layer1" "material 1"),("layer2" "material 2"),("layer3" "material 3") i wan to pass values from command line to my lisp program in my lisp program already list is there for materil and layer ..insted of predefining that i want to pass value from command line... =========sample program====== (defun c:pumat(/ Lst sSet mLst cMat sCnt lCnt mCnt eCnt) (vl-load-com) (setq Lst (list ' ("0" "Global") ' ("layer1" "material 1") ' ("layer1" "material 2") ); end list ); end setq (vl-load-com) (if(setq sSet(ssget "_X" '((0 . "*SOLID")))) (progn (setq sCnt 0 lCnt 0) (vlax-for mat (vla-get-Materials (vla-get-ActiveDocument (vlax-get-acad-object))) (setq mLst(cons(vla-get-Name mat)mLst)) ); end vlax-for (foreach itm (mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr(ssnamex sSet)))) (if(setq cMat (cadr (assoc (setq cLay(vla-get-Layer itm))Lst))) (if(member cMat mLst) (if(vl-catch-all-error-p (vl-catch-all-apply 'vla-put-Material (list itm cMat))) (setq lCnt(1+ lCnt)) (setq sCnt(1+ sCnt)) ); end if (if(not(member cMat mCnt)) (setq mCnt(cons cMat mCnt)) ); end if ); end if (if(not(member cLay eCnt)) (setq eCnt(cons cLay eCnt)) ); end if );end if ); end foreach (if(or(/= 0 lCnt)(/= 0(length mCnt))(/= 0(length eCnt))) (progn (princ "\n========================= ERROR LIST =========================\n") (if(/= 0(length mCnt)) (progn (princ "\nFollowing materials missed in drawing: \n") (foreach mat mCnt (princ(strcat "\n " mat)) ); end foreach (princ "\n") ); end progn ); end if (if(/= 0(length eCnt)) (progn (princ "\nSome solid layers missed in list: \n") (foreach lay eCnt (princ(strcat "\n " lay)) ); end foreach (princ "\n") ); end progn ); end if (if(/= 0 lCnt) (princ(strcat "\n" (itoa lCnt) " were on locked layer!\n")) ); end if (princ "\n========================== END LIST ==========================\n") (textscr) ); end progn ); end if (princ(strcat "\n (itoa sCnt) " of " (itoa(sslength sSet)) " solids >>>")) ); end progn (princ "\n No Solids Found ") ); end if (princ) ); end of c:pumat Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now