Message 1 of 8
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I would like to use ObjectDBX in order to generate multiple "virtual" lines in an "acdbobj" and finally copy them back to the current AutoCAD document.
Is it possible to generate a line in "acdbobj" simply using:
(setq lineObj (vlax-invoke (vla-get-ModelSpace (vla-get-Database doc)) 'addline pt1 pt2)
Is "acdbobj" what is usually called the database object?
The purpose of this test is to find out, wether using ObjectDBX will fasten looping.
(vl-load-com) (defun c:addrdlines (/ bw nl r1 r2 pt1 pt2 lineObj dbp) (setq acadObj (vlax-get-acad-object) c_doc (vla-get-Activedocument acadObj) modelSpace (vla-get-ModelSpace c_doc) ) ;; Load the ObjectDBX library (if (= acLibImport nil) (progn (vlax-import-type-library :tlb-filename "C:\\Program Files\\Common Files\\Autodesk Shared\\axdb21enu.tlb" :methods-prefix "acdbm-" :properties-prefix "acdbp-" :constants-prefix "acdbc-" ) (setq acLibImport T) ) ) ;; Create a reference to the ObjectDBX object (setq acdbObj (vlax-create-object "ObjectDBX.AxDbDocument.21")) (setq bw 100. ;box width nl 10 ;number of lines ) ;; CREATE LINES IN MODELSPACE OF acdbObj
;; ??? (repeat nl (setq r1 (* (LM:rand) bw) r2 (* (LM:rand) bw) pt1 (list 0. r1 0.) pt2 (list bw r2 0.) ) (setq lineObj (vlax-invoke modelSpace 'addline pt1 pt2)) ;random line / distance between points ) ;end repeat ;; COPY ALL LINES FROM MODELSPACE "acdbObj" to MODELSPACE "acadObj"
;; ???
;; Close the in memory drawing
(vlax-release-object acdbObj) ) ;end defun ;;;LM:rand (defun LM:rand (/ a c m) (setq m 4294967296.0 a 1664525.0 c 1013904223.0 $xn (rem (+ c (* a (cond ($xn) ((getvar 'date)) ) ) ) m ) ) (/ $xn m) )
Solved! Go to Solution.