AutoCAD Architecture Customization
Welcome to Autodesk’s AutoCAD Architecture Customization Forums. Share your knowledge, ask questions, and explore popular AutoCAD Architecture Customization topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Need some ActiveX help - calling James Buzbee or Dean McCarns and others...

3 REPLIES 3
Reply
Message 1 of 4
Anonymous
288 Views, 3 Replies

Need some ActiveX help - calling James Buzbee or Dean McCarns and others...

Simple routine (c:ChangeWall below) that crashes and gives me an "Exception
occurred" error. What am I doing wrong? Thanks, Craig


(defun c:ChangeWall (/ wallobj p1 p2 pt1 pt2)
(setq acad (vlax-get-acad-object)
thisDrawing (vlax-get acad "activedocument")
modelspace (vlax-get thisDrawing "modelspace"))

(setq wallobj (vlax-ename->vla-object (car (entsel "\nSelect a Wall: ")))
p1 (getpoint "\nWall start point: ")
p2 (getpoint "\nWall end point: ")
pt1 (listToVariantArray p1 vlax-vbDouble)
pt2 (listToVariantArray p2 vlax-vbDouble)
)
(vlax-put wallobj 'startpoint pt1)
(vlax-put wallobj 'endpoint pt2)
(princ)
)

; support code below

(defun lisp-value (v) ; the Holy Grail of vla->lisp conversion? 😉
;; Copyright 2002 Vladimir Nesterovsky.
;; Free for use by any commercial entity with
;; less then $100 million annual revenue.
(cond
((= (type v) 'variant)
(lisp-value (variant-value v)))
((= (type v) 'safearray)
(mapcar 'lisp-value (safearray-value v)))
(T v)
)
)

;;Frank Oquendo acadx.dwg
(defun listToVariantArray (lst varType)
(vlax-make-variant
(vlax-safearray-fill
(vlax-make-safearray
varType
(cons 0 (1- (length lst)))
)
(mapcar
'(lambda (x)
(cond
((= (type x) 'list)
(vlax-safearray-fill
(vlax-make-safearray
(if (apply '= (mapcar 'type x))
(cond
((= (type (car x)) 'REAL) vlax-vbDouble)
((= (type (car x)) 'INT) vlax-vbInteger)
((= (type (car x)) 'STR) vlax-vbString)
)
vlax-vbVariant
)
(cons 0 (1- (length x)))
)
x
)
)
((= (type x) 'ename)
(vla-get-objectid (vlax-ename->vla-object x))
)
(t x)
)
)
lst
)
)
)
)
3 REPLIES 3
Message 2 of 4
Anonymous
in reply to: Anonymous

(defun c:ChangeWall (/ wallobj p1 p2)
(setq acad (vlax-get-acad-object)
thisDrawing (vlax-get acad "activedocument")
modelspace (vlax-get thisDrawing "modelspace"))

(setq wallobj (vlax-ename->vla-object (car (entsel "\nSelect a Wall: ")))
p1 (getpoint "\nWall start point: ")
p2 (getpoint "\nWall end point: ")
)
(vlax-put wallobj 'startpoint p1)
(vlax-put wallobj 'endpoint p2)
(princ)
)

Not as difficult as you thought: vlax-put accepts care lisp data types:
strings, lists, reals, etc. So just use the values returned by getpoint!
Message 3 of 4
Anonymous
in reply to: Anonymous

So, in the example above, do you even need to set the "acad", "thisDrawing"
and "modelspace" variables? I don't see where they are used...



"James Buzbee" wrote in message
news:5699242@discussion.autodesk.com...
(defun c:ChangeWall (/ wallobj p1 p2)
(setq acad (vlax-get-acad-object)
thisDrawing (vlax-get acad "activedocument")
modelspace (vlax-get thisDrawing "modelspace"))

(setq wallobj (vlax-ename->vla-object (car (entsel "\nSelect a Wall: ")))
p1 (getpoint "\nWall start point: ")
p2 (getpoint "\nWall end point: ")
)
(vlax-put wallobj 'startpoint p1)
(vlax-put wallobj 'endpoint p2)
(princ)
)

Not as difficult as you thought: vlax-put accepts care lisp data types:
strings, lists, reals, etc. So just use the values returned by getpoint!
Message 4 of 4
Anonymous
in reply to: Anonymous

Thanks James- you helped me over the hurdle.. I posted a routine to this NG
called "Lisp routine: snap objects to nearest "SNAPUNIT". I used it to fix
some inaccurately drawn walls.


"James Buzbee" wrote in message
news:5699242@discussion.autodesk.com...
(defun c:ChangeWall (/ wallobj p1 p2)
(setq acad (vlax-get-acad-object)
thisDrawing (vlax-get acad "activedocument")
modelspace (vlax-get thisDrawing "modelspace"))

(setq wallobj (vlax-ename->vla-object (car (entsel "\nSelect a Wall: ")))
p1 (getpoint "\nWall start point: ")
p2 (getpoint "\nWall end point: ")
)
(vlax-put wallobj 'startpoint p1)
(vlax-put wallobj 'endpoint p2)
(princ)
)

Not as difficult as you thought: vlax-put accepts care lisp data types:
strings, lists, reals, etc. So just use the values returned by getpoint!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost