Jump to content

LISP Program to read csv file and place text


Recommended Posts

Posted

Update the Demo function... remove left-over vl function

 

The error could be an entirely different issue. not sure.. i'll check with you guys tomorrow.

 

@cwake

I'll get back to you as i'm headed out the door. :lol:

 

Cheers

  • Replies 25
  • Created
  • Last Reply

Top Posters In This Topic

  • cwake

    10

  • terra1982

    8

  • pBe

    5

  • satishrajdev

    2

Top Posters In This Topic

Posted

Thanks, will try that later today

 

Gotta go to work now, bring out the TerraModel...

 

Thanks!!

Posted

I've found an online reference. It would take more time than I've got to go through each function in the routine, but it does appear that the "getfiled" function does not support a bit flag of 16.

 

Update the Demo function... remove left-over vl function

I also think that pBe is right - there doesn't appear to be a "vl-string-position" function in intellicad either.

Posted (edited)

I can't help myself. I hope you don't mind me working with your code pBe. It didn't have the ActiveX in it so to me it was a better place to start.

I haven't looked at EVERY function's arguments, but I've taken out the functions that don't appear to be supported in Intellicad, viz. "vl-string-position" and "layoutlist". I've also changed the "getfiled" bit flag to 4 as 16 doesn't appear to be supported... though now I'm thinking that shouldn't matter in a bitflag??

Here's hoping Mark.

 

Edit - Oops. Sorry, I didn't realise that you had already redefined _delFinder in your previous post pBe. Layoutlist might still be worth removing though?

 

(defun c:demo ( / _delFinder collect _remd file data p )
 ;; pBe Dec 2013 ;;
 ;*******************************************************************
 (defun _delFinder ( str / a b res )
   (setq a "")
   (while (/= (setq b (substr str 1 1)) "")
     (if (= b ",")
       (setq res (cons a res)
             a ""
             str (substr str 2)
             )
       (setq a (strcat a b)
             str (substr str 2)
             )
       )
     )
   (reverse (cons a res))
   )
 ;*******************************************************************
 (setq collect (lambda (f / a b opf)
                 (setq opf (open f "r"))
                 (read-line opf)
                 (while (setq a (read-line opf))
                   (setq b (cons (_delfinder a) b))
                   )
                 (close opf)
                 b
                 )
       )
 ;*******************************************************************
 (setq _remd (lambda (lst / a b)
               (while (setq a (car lst))
                 (setq b (if (not (member a b))
                             (cons a b)
                             b
                             )
                       lst (cdr lst)
                       )
                 )
               b
               )
       )
 ;*******************************************************************
 (and
   (setq
     file (getfiled "Select Data file" (getvar 'dwgprefix) "csv" 4)
     )
   (setq data (collect file))
   (foreach itm (_remd (mapcar 'car data))
     (if (snvalid itm)
       (command "_.layout" "_New" itm)
       )
     itm
     )
   (foreach itm (_remd (mapcar 'cadr data))
     (if (and (not (tblsearch "Layer" itm))
              (snvalid itm)
              )
       (entmake (list (cons 0 "LAYER")
                      (cons 100 "AcDbSymbolTableRecord")
                      (cons 100 "AcDbLayerTableRecord")
                      (cons 2 itm)
                      (cons 70 0)
                      )
                )
       itm
       )
     )
   (foreach itm (_remd (mapcar 'caddr data))
     (if (and (not (tblsearch "Style" itm))
              (snvalid itm)
              )
       (entmake (list '(0 . "STYLE")
                      '(100 . "AcDbSymbolTableRecord")
                      '(100 . "AcDbTextStyleTableRecord")
                      (cons 2 itm)
                      '(70 . 0)
                      '(40 . 0.0125) ;<-- Text height for style
                      '(41 . 0.
                      '(50 . 0.0)
                      '(71 . 0)
                      '(3 . "ARIAL.TTF")
                      '(4 . "")
                      )
                )
       itm
       )
     )
   (foreach info data
     (entmakex
       (list
         (cons 0 "TEXT")
         (cons
           10
           (setq p (list (distof (nth 3 info)) (distof (nth 4 info))))
           )
         (cons 11 p)
         (cons 8 (cadr info))
         (cons 7 (caddr info))
         '(40 . 0.0125)
         (cons 1 (nth 5 info))
         '(71 . 0)
         '(72 . 1)
         '(73 . 2)
         (cons 410 (car info))
         )
       )
     )
   )
 (princ)
 )

Edited by cwake
Posted

and... my further research suggests that Intellicad uses the same dictionary name as AutoCAD... so that Intellicad developers create their own function, something like...

(defun icadlayoutlist ( / ll)
 (foreach a (dictsearch (namedobjdict) "ACAD_LAYOUT")
   (if (= (car a) 3)
     (setq ll (cons (cdr a) ll))
     )
   )
 ll
 )

Posted

Just a side issue if your going to play with title blocks in different layouts then no way put text on the layout, rather go directly inside the title "BLOCK" and update the title block attributes a far better way to do it. Heaps of code around on how to do.

 

I have written stuff for Intellicad and its pretty good in coding in Autocad then running in Intellicad you get a few quirks and have to work around it. It was a few years ago, anyone Intellicad support VL ? Does Intellicad still support VBA it used to ?

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