PDA

View Full Version : Creating and exporting Lists - VBA or Lisp?



kcarlsen
2004-12-31, 05:29 PM
I would like to create a routine that will allow a user to select points on a drawing, assign an ID, then create a list containing the ID and the X,Y & Z coordinates of that point. The file will then be exported for use in a modeling program. I have one AutoLisp class under my belt and very limited knowledge of VBA. I am confident I can create a routine in Lisp but is VBA a better tool for creating, exporting and importing lists?

RobertB
2004-12-31, 09:28 PM
Either would be adequate for the task. In fact, the user interaction would be better in AutoLISP as selection set filtering is better in that language.

mtuersley
2005-01-06, 06:01 AM
Hmmm.....it'd depend upon his user interaction and what his definition is of exporting the list. If he needs a GUI, I sure as H-E-double_hockey_sticks wouldn't want to do it in DCL! If his definition of exporting is into another program and not just a simple text file, I wouldn't use lisp either. And for what he's looking to have selected, his filtering would be minimal and wouldn't lean to lisp [can you tell I avoid lisp like the plague since being converted to the "dark side"].

Go with whatever you are more comfortable with. There are ample resources for both languages available on the web. Personally, I'd say vba.

But, if it were me, I'd confuse the whole issue and say C# :) Best of both worlds especially if he waits to do it in ACAD2006!

RobertB
2005-01-06, 07:07 AM
Well, of course, if you want to include the kitchen sink! ;)

peter
2005-01-10, 12:52 PM
I of course would say lisp.

The lisp solution might be one of these two options.
The first allows the user to enter an id name and select a point using getpoint.
The second options allows the user to select a point entity on screen.

Hope it helps.

Peter Jamtgaard



(defun C:ExportPoints (/ lstIDPoints lstPoint strPoint)
(while (/= (setq strPoint (getstring "\nEnter Point ID: ")) "")
(setq lstPoint (getpoint "\nEnter Point On Screen: ")
lstIDPoints (cons (strcat strPoint
","
(rtos (car lstPoint) 2)
","
(rtos (cadr lstPoint) 2)
","
(rtos (caddr lstPoint) 2)
)
lstIDPoints
)
)
)
(writePoints lstIDPoints)
)
(defun C:ExportPOints2 (/ intCount lstEntity lstInsertion ssSelections)
(princ "\nSelect Points: ")
(setq ssSelections (ssget (list (cons 0 "POINT"))))
(repeat (setq intCount (sslength ssSelections))
(setq intCount (1- intCount)
lstEntity (entget (ssname ssSelections intCount))
lstInsertion (cdr (assoc 10 lstEntity))
lstIDPoints (cons (strcat (cdr (assoc 5 lstEntity)) ; Handle as ID
","
(rtos (car lstInsertion) 2)
","
(rtos (cadr lstInsertion) 2)
","
(rtos (caddr lstInsertion) 2)
)
lstIDPoints
)

)
)
(writePoints lstIDPoints)
)

(defun WritePoints (lstIDPoints / filIDPoints strIDPoint)
(if lstIDPoints
(progn
(setq filIDPoints (open "mypoints.csv" "w"))
(foreach strIDPoint (reverse lstIDPoints)
(write-line strIDPoint filIDPoints)
)
(close filIDPoints)
)
)
)