dgp 发表于 2022-7-5 22:26:20

Auto lisp (link excel and auto

Hello,
I’m having difficulty using Auto lisp and I’m wondering if anyone can help me out.
I’m looking for a way to link both an excel table and an AutoCAD drawing together, where if I plug a number into the excel cell it will automatically change a property shape in the AutoCAD drawing to a certain color. I will have 10 different colors and a few hundred property shapes.
 
For example:
 
In excel: If I plug in the following values;
 
 
 
Property Number/        Color Value/                                  Property Shape in autocad
200   /                             1 /                                     Property turns green
300           /                           2 /                                     Property turns red
400          /                              1 /                                     Property turns green
 
Thanks

BIGAL 发表于 2022-7-5 23:50:25

This has been done before this is a good starting point.
 
Found

(defun HATLOT (lotnum col / HATOBJ FPTS PT1 TPT )(SETQ OLDSNAP (GETVAR "OSMODE"))(SETVAR "OSMODE" 0)(setq lotfound (ssget "X" (LIST (CONS 0 "MTEXT")(CONS 1 lotnum)(CONS 8 "C-BLDG-NMBR"))))(SETQ TPT (ASSOC 10 (ENTGET (ssname lotfound 0))))(SETQ PT1 (LIST (NTH 1 TPT)(NTH 2 TPT)))(SETQ FPTS (LIST (POLAR PT1 1.57 2 ) PT1)) ; 2 is a dummy value just past text hole(SETQ HATOBJ (ENTGET (SSNAME (SSGET "f" FPTS '((0 . "HATCH"))) 0)))(ENTMOD (subst col (assoc 8 HATOBJ) HATOBJ))); this is where you would loop through the lots csv from excel number - color;(while read csv(setq lotnum (getstring "\nEnter lot number")) ; read from file(SETQ COL (cons 8 "60% complete")) ; dummy line for testing make value read from file(HATLOT lotnum perc) ; end while(setvar "osmode" oldsnap)(princ)
页: [1]
查看完整版本: Auto lisp (link excel and auto