Jump to content

Recommended Posts

Posted

Hi Lee Mac

 

that looks great but when i load the lisp through appload and then type xc into the comman line it does not do anything? am I loading it wrong?

  • Replies 29
  • Created
  • Last Reply

Top Posters In This Topic

  • GlnGrnr

    10

  • Tharwat

    7

  • alanjt

    4

  • pBe

    4

Top Posters In This Topic

Posted

I see no error in the code (unless I have missed something) - I can only assume that matches are found with your layer names...

Posted

i think you may be right, i dont think it has found the xrefs loaded into the drawing as a match. could it be the wildcard (*)

Posted

Yes thats right | i am ot sure why it wont run as i cannot see the issue either, i have even tried renaming the xref list to match that of the drawing but still no joy, thanks for all your help so far means alot with a project this size

Posted

Still using command: Layer

 

(defun c:xcs (/ a col xrs nme p col)
 (setvar 'cmdecho 0)
 (setq lst	'(("AC" . 1)
  ("_BM" . 2)
  ("_CL" . 3)
  ("_EC" . 4)
  ("_FE" . 5)
  ("_FL" . 6)
  ("_FP" . 7)
  ("_GC" . 11)
  ("_HD" . 41)
  ("_HO" . 71)
  ("_HW" . 91)
  ("_MW" . 121)
  ("_PA" . 151)
  ("_RE" . 171)
  ("_RP" . 191)
  ("_SL" . 211)
  ("_TL" . 241)
  ("_ZA" . 222)
  ("_ZB" . 144)
  ("_ZC" . 30)
 )
 )
 (while (setq a (tblnext "block" (not a)))
   (if	(and
  (setq nme (cdr (assoc 1 a)))
  (setq	p (vl-string-position
	    95
	    (setq sf (vl-filename-base nme))
	    nil
	    t
	  )
  )
  (setq col (assoc (substr sf (1+ p)) lst))
)
     (command "_layer"
       "_color"
       (cdr col)
       (strcat sf "|*")
       ""
     )
   )
 )
 (princ)
)

Posted

Try this UNTESTED codes and let me know .

 

(vl-load-com)
(defun c:Test (/ l doc)
 (setq l '((1 "0618__AC")
           (2 "0618__BM")
           (3 "0618__CL")
           (4 "0618__EC")
           (5 "0618__FE")
           (6 "0618__FL")
           (7 "0618__FP")
           (11 "0618__GC")
           (41 "0618__HD")
           (71 "0618__HO")
           (91 "0618__HW")
           (121 "0618__MW")
           (151 "0618__PA")
           (171 "0618__RE")
           (191 "0618__RP")
           (211 "0618__SL")
           (241 "0618__TL")
           (222 "0618__ZA")
           (144 "0618__ZB")
           (30 "0618__ZC")
          )
 )
 (vlax-for x
           (vla-get-layers
             (setq doc (vla-get-activedocument (vlax-get-acad-object)))
           )
   (foreach xr l
     (if (wcmatch (strcase (vla-get-name x)) (strcat (cadr xr) "|*"))
       (vla-put-color x (car xr))
     )
   )
 )
 (vla-regen doc acAllViewports)
 (princ)
)

Posted

pBe, code works fantastic, thankyou everyone for your help on this you have just saved me approximately 35 days of work load. :o) i have been trying to learn lsp but have been so over loaded with work I have nto got much further than the tutorials. once again thanks for your help

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...