andy_06 发表于 2022-7-5 17:27:37

 
 
 
Hi, thanks for trying that but it didn't quite work (it brings up a message in the command line saying 'too many items to intersect'. It then runs the routine but puts the lineweight 0.50mm onto the "0" layer and doesn't delete the 'Cyan' colours or move the colour 35 lines onto "0".
Please don't worry though as the previous one almost does everything that I am looking for so that is still a big help!

Grrr 发表于 2022-7-5 17:32:39

I may messed up (cond) Try this one:

(defun C:test ( / lyr1 lyr0 acDoc emakeLay SSX i e enx ce )(setq lyr1 "Layer 1");

MillerMG 发表于 2022-7-5 17:36:35

I would have used the SELECTSIMILAR for most of this. For almost every single thing you needyou could have set your settings to your requirements and simply changed the layer/color and what not.

andy_06 发表于 2022-7-5 17:37:17

 
 
Thanks again, that is almost there!
The only thing is it puts the Colour 35 items onto the "0existing" layer instead of the "0" layer but apart from that it does everything I need!

Grrr 发表于 2022-7-5 17:40:48

 
Corrected the code in my last post. Sorry, it was confusing with these "0" and "0existing" layer names.

andy_06 发表于 2022-7-5 17:46:12

 
Wow thank you, that is everything that I need. Hopefully you won't here from me again!

Aftertouch 发表于 2022-7-5 17:48:38

I was following this topic, and i need a similair LISP, but instead of checking for lineweights, i need a check for linetypes.
Im trying to edit the code above myself, but i dont understand how you check for lineweight properties... i just cant find the logic in the code.
 
Is is easy to edit this code to:
- check all objects in the drawing...
- if something has the property : Linetype Hidden...
- change it so : Linetype Hidden2.
- and if its dashed, change it to dashed2...
 
entire drawing, including blocks etc... so hidden and dashed can be purged...
I need a specific check on the 'properties' part, not a check on the layermanager. (got that one solved already. :-))

Grrr 发表于 2022-7-5 17:52:33

Not sure will this work, please reply after testing it:

(defun C:test ( / blkdef e enx i lckd ssx subent subenx )(vlax-for x (vla-get-Layers (vla-get-ActiveDocument (vlax-get-acad-object)))         (if (= (vla-get-Lock x) :vlax-true)                 (progn                        (vla-put-Lock x :vlax-false)                        (setq lckd (cons x lckd))                )        ))(while (setq blkdef (tblnext "BLOCK" (not blkdef)))        (setq subEnt (cdr (assoc -2 blkdef)))        (while subEnt                (setq subEnx (entget subEnt))                (if (assoc 6 subEnx)                        (cond                                ((= (strcase (cdr (assoc 6 subEnx))) "HIDDEN")                                        (setq subEnx (subst (cons 6 "HIDDEN2") (assoc 6 subEnx) subEnx))                                        (entupd (cdr (assoc -1 (entmod subEnx))))                                )                                ((= (strcase (cdr (assoc 6 subEnx))) "DASHED")                                        (setq subEnx (subst (cons 6 "DASHED2") (assoc 6 subEnx) subEnx))                                        (entupd (cdr (assoc -1 (entmod subEnx))))                                )                        ); cond                )                (setq subEnt (entnext subEnt))        )               (entupd (tblobjname "BLOCK" (cdr (assoc 2 blkdef)))))(if (setq SSX (ssget "_X"))        (repeat (setq i (sslength SSX))                (setq e (ssname SSX (setq i (1- i))))                (setq enx (entget e))                (if (assoc 6 enx)                        (cond                                ((= (strcase (cdr (assoc 6 enx))) "HIDDEN")                                        (setq enx (subst (cons 6 "HIDDEN2") (assoc 6 enx) enx))                                        (entupd (cdr (assoc -1 (entmod enx))))                                )                                ((= (strcase (cdr (assoc 6 enx))) "DASHED")                                        (setq enx (subst (cons 6 "DASHED2") (assoc 6 enx) enx))                                        (entupd (cdr (assoc -1 (entmod enx))))                                )                        ); cond                )        ))(if lckd (mapcar '(lambda (x)(vla-put-Lock x :vlax-true) ) lckd))(vla-Regen (vla-get-ActiveDocument (vlax-get-acad-object)) acAllViewports)(vla-ZoomExtents (vlax-get-acad-object))(princ))

Aftertouch 发表于 2022-7-5 17:52:54

Thanks for the code Grrr!
The part of the code where the linetypes get replaced seems to work fine.
Tho... the part where it checks the contents of BLOCKS doent nothing. But doenst give an error message.
It just does not change the linetype inside the blocks.
 
Hope this can be fixed. :-)

Grrr 发表于 2022-7-5 17:57:50

 
Hmm, I can't seem to find the problem, edited the code to regen All viewports (the red text). If it still doesn't work I will try to re-write the block iteration with visual lisp.
页: 1 [2]
查看完整版本: LISP例程选择linewei