Jump to content

Help to combine 2 lisp program


shamsam1
 Share

Recommended Posts

i have 2 lisp program i want to combine it and make it once ,please guide me how to proceed

 

fisrt lisp program to change layer color

second lisp program to add materiel to layer

 

insted of list i want a function whee i am mention either layer name and color or layer name and material..

 

 

 

'''change layer color

(defun c:layd(/ Lst curLay fLst laySet)

 

(setq Lst (list

'("layer1" 10)

'("layer2" 20)

 

); end list

); end setq

 

(vl-load-com)

 

(foreach lay Lst

(if

(not

(vl-catch-all-error-p

(setq curLay(vl-catch-all-apply 'vla-Item

(list(vla-get-Layers

(vla-get-ActiveDocument

(vlax-get-acad-object)))(car lay))))))

(progn

(vla-put-Color curLay(cadr lay))

(setq fLst(list(cons 8(vla-get-Name curLay))))

(if

(setq laySet(ssget "_X" fLst))

(progn

(foreach itm

(mapcar 'vlax-ename->vla-object

(vl-remove-if 'listp

(mapcar 'cadr(ssnamex laySet))))

(vla-put-Color itm acByLayer)

); end foreach

); end if

); end progn

); end progn

); end if

); end foreach

(princ)

); end of c:layd

'''--------------

'''''''-----attach materil

(defun c:pumat(/ Lst sSet mLst cMat sCnt lCnt mCnt eCnt)

 

(vl-load-com)

 

(setq Lst (list

' ("0" "Global")

' ("layer1" "BLUE GLASS")

' ("3_250580E" "BLUE GOOSE")

); 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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...