pmxcad Posted February 16, 2018 Share Posted February 16, 2018 Hello, iam using Lee`s Lisp to make a bounding box. But it gives a ERROR. error: no function definition: LM:SSBOUNDINGBOX. (defun c:test ( / box obj sel spc ) ;(setq all (ssget "_W" '(0 0) '(1000 1000))) ;(setq all (ssget "_x" '((410 . "Model")))) ; (if (and (setq sel (ssget "P")) (if (and (setq sel (ssget)) (setq box (LM:ssboundingbox sel)) ) (progn (setq spc (vlax-get-property (vla-get-activedocument (vlax-get-acad-object)) (if (= 1 (getvar 'cvport)) 'paperspace 'modelspace ) ) ) (if (equal 0.0 (apply '- (mapcar 'caddr box)) 1e-6) (progn (setq obj (vlax-invoke spc 'addlightweightpolyline (apply 'append (mapcar '(lambda ( x ) (mapcar '(lambda ( y ) ((eval y) box)) x)) '( (caar cadar) (caadr cadar) (caadr cadadr) (caar cadadr) ) ) ) ) ) (vla-put-closed obj :vlax-true) (vla-put-elevation obj (caddar box)) ) (apply 'vlax-invoke (vl-list* spc 'addbox (apply 'mapcar (cons '(lambda ( a b ) (/ (+ a b) 2.0)) box)) (apply 'mapcar (cons '- (reverse box))) ) ) ) ) ) (princ) ) (vl-load-com) (princ) I want to use this lisp to obtain the dimensions (height and width) of everything in model space such as zoom extents. This is to later automatically make the choice to select the paper format / frame and insert it. I have checked on the internet if there is a lisp that can get the dimensions, but not found. So I started to make a selection / bounding box. So does anyone know where that error comes from? Thanks in advance. PmxCAD Quote Link to comment Share on other sites More sharing options...
rlx Posted February 16, 2018 Share Posted February 16, 2018 (edited) Hi pmccad, your code looks broken. Defun is closed right after the ...sel))). Is Lee's function loaded first? anyways , last week wrote an app to be able to get the extents from a drawing without opening it (odbx) (defun Odbx_Extents ( / acApp acDocs Odbx now-open) (Init)(getfile)(cleanUp)(princ)) (defun Init ( / s v x) (setq acApp (vlax-get-acad-object) v (atoi (getvar 'acadver)) acDocs (vla-get-documents acApp) s "objectdbx.axdbdocument" Odbx (vl-catch-all-apply 'vla-getinterfaceobject (list acApp (if (< v 16) s (strcat s "." (itoa v)))))) (vlax-for x acDocs (setq now-open (cons (cons (strcase (vla-get-fullname x)) x) now-open))) ) (defun GetFile ( / fn doc result) (if (and (setq fn (getfiled "Select vendor block drawing" "c:/temp/" "dwg" 0)) (or (setq doc (cdr (assoc (strcase fn) now-open))) (and (not (vl-catch-all-error-p (vl-catch-all-apply 'vla-open (list Odbx fn))))(setq doc Odbx)))) (progn (if (setq result (process doc))(progn (princ "\nResult : ")(princ result))(princ "\nNothing to show"))) (princ (strcat "\nError opening file: " (vl-filename-base fn) ".dwg")) ) ) (defun process ( %doc / layout obj ll ur ll-lst ur-lst) (vlax-for layout (vla-get-layouts %doc) (vlax-for obj (vla-get-block layout) (if (vlax-method-applicable-p obj 'getboundingbox) (if (not (vl-catch-all-error-p (vl-catch-all-apply 'vla-getboundingbox (list obj 'll 'ur)))) (setq ll-lst (cons (vlax-safearray->list ll) ll-lst) ur-lst (cons (vlax-safearray->list ur) ur-lst)))))) (if (and ll-lst ur-lst) (list (apply 'mapcar (cons 'min ll-lst))(apply 'mapcar (cons 'max ur-lst)))) ) (defun CleanUp () (odbx_releaseall) ) (defun odbx_releaseall () (mapcar '(lambda (x) (if (and (= 'vla-object (type x)) (not (vlax-object-released-p x)))(vlax-release-object x))(set (quote x) nil)) (list Odbx acDocs acApp))(gc)) ; (Odbx_Extents) maybe it's of use to you. gr. Rlx Edited February 16, 2018 by rlx Quote Link to comment Share on other sites More sharing options...
pmxcad Posted February 16, 2018 Author Share Posted February 16, 2018 Hi RLX, Yeb, right, first load another routine from Lee. Works again. But to come back to your routine, how does the routine awaken, drag in the drawing ?. I do not see any (defun c: .... and can I get the dimensions from variables somewhere? (Height length) PmxCAD Quote Link to comment Share on other sites More sharing options...
rlx Posted February 16, 2018 Share Posted February 16, 2018 You have to load it (obviously) and then type (Odbx_Extents) , that is with 'de haakjes' You will then have to select a drawing (for testing I used "c:/temp/" in the getfiled command but you can use any other start folder or just use "" ) it will proces the drawing , dont select a very large drawing , i wrote it to get the size for symbols or titleblocks. When its done it will return a list with the size similar to extmin / extmax. something like '((-567500.0 -22.4588 -1.0e-05) (605.054 1.1125e+06 0.1)) Thats why I didn't use c: in the command because it should be used with a program something like (setq symbol-size (Odbx_Extents)) and then the calling program can use this information for further processing. gr. Rlx Quote Link to comment Share on other sites More sharing options...
BIGAL Posted February 18, 2018 Share Posted February 18, 2018 My simplest way is to check if another program is loaded this way only need 1 line in the code versus copying the whole defun etc. (if (not LM:SSBOUNDINGBOX)(load "lee-macs boundingbox.lsp")) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.