Jump to content

Auto lisp (link excel and autocad)


dgp

Recommended Posts

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

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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