Message 1 of 9
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm tying to create a revolved solid from a list of LISP generated points that will define a polyline from which a region is defined. The program creates the polyline but throws an error at line 32 -
"Points = #<safearray...>; error: bad argument type: safearrayp nil"
What is the correct code for this task?
Thank you.
(vl-load-com)
(defun c:Example_myRevolvedSolid ()
(setq acadObj (vlax-get-acad-object))
(setq doc (vla-get-ActiveDocument acadObj))
(setq p1 '(5 2 0))
(setq w 7.0
h 3.0
)
(setq points (vlax-make-safearray vlax-vbDouble '(0 . 14)))
(vlax-safearray-fill points (list (car p1)
(cadr p1)
(caddr p1)
(+ (car p1) w)
(cadr p1)
(caddr p1)
(+ (car p1) w)
(+ (cadr p1) h)
(caddr p1)
(car p1)
(+ (cadr p1) h)
(caddr p1)
(car p1)
(cadr p1)
(caddr p1)
))
;; Create a lightweight Polyline object in model space
(setq modelSpace (vla-get-ModelSpace doc))
(setq plineObj (vla-AddPolyline modelSpace points))
(vlax-safearray-put-element curves 0 plineObj) ;<------- bad argument type
(setq regionObj (vla-AddRegion modelSpace curves))
(vla-ZoomAll acadObj)
(alert "Revolve the region to create the solid.")
;; Define the rotation axis
(setq rotAxisPt (vlax-3d-point 0 0 0)
rotAxisDir (vlax-3d-point 1 0 0)
rotAngle 180)
;; Create the solid
(setq solidObj (vla-AddRevolvedSolid modelSpace (vlax-safearray-get-element (vlax-variant-value regionObj) 0) rotAxisPt rotAxisDir rotAngle))
(setq NewDirection (vlax-3d-point -1 -1 1))
(setq activeViewport (vla-get-ActiveViewport doc))
(vla-put-Direction activeViewport NewDirection)
(vla-put-ActiveViewport doc activeViewport)
(vla-ZoomAll acadObj)
(alert "Solid created.")
)
lee.minardi
Solved! Go to Solution.