PDuMont Posted May 23, 2016 Posted May 23, 2016 Hello All, Has anyone else noticed inaccuracies with vla-getboundingbox? Within a lisp, I am trying to establish 2 points to make a window selection, but the bounding box does not enclose the object. Any ideas? Thanks Screen shot: test.dwg Quote
Jeffrey_B Posted May 23, 2016 Posted May 23, 2016 Make sure you turn "osnaps" off before creating your bounding box. It's good practice to store the current osnaps valve to a localized variable, set it to zero, draw the bounding box, and then restore the osnaps back to what the user previously had. There are plenty of examples of this on the forums. Sent from my SM-G935V using Tapatalk Quote
PDuMont Posted May 23, 2016 Author Posted May 23, 2016 Sure enough, that was the problem. So simple I couldn't catch it... Thank you Jeffery_B Quote
Jeffrey_B Posted May 23, 2016 Posted May 23, 2016 You're welcome! I struggled with the same thing when I started using bounding boxes. Sent from my SM-G935V using Tapatalk Quote
Lee Mac Posted May 23, 2016 Posted May 23, 2016 I would suggest entmake'ing your bounding box as opposed to using command calls, so that Object Snap has no effect. Here is an example: Bounding Box. Quote
PDuMont Posted May 23, 2016 Author Posted May 23, 2016 Thank you Lee, that would definitely make it more bullet proof. Quote
PDuMont Posted May 23, 2016 Author Posted May 23, 2016 Well since you guys have been so helpful. I have one (so far), other issue with this particular routine. This routine sometimes offsets the object to the wrong side. Am I wrong in thinking that: (vla-offset obj -0.375) would offset the object to the "inside"? The error occurs with the polyline object in the attached dwg in the first post. Sloppy and probably terribly inefficient code: ;| PLEX CIRCLE OFFSET DRAWS CLEARANCE HOLES AND OFFSETS CIRCLES FOR COUNTERSINK WRITTEN BY P.DuMONT 02/18/2016 |; (defun c:PLO ( / cmde doc osn dia ent obj point1 point2 ln sset mx d0 pt di ) (defun *error* (msg) (if (and msg (not (wcmatch (strcase msg t) "*break,*cancel*,*exit*")) ) (princ (strcat "\nError: " msg)) ) (if cmde (setvar 'cmdecho cmde) ) (if doc (vla-endundomark doc) ) (if osn (setvar 'osmode osn) ) (princ) ) ;_ end of defun (setq doc (vla-get-activedocument (vlax-get-acad-object))) (vla-startundomark doc) (setvar 'cmdecho 0) (setq osn (getvar 'osmode)) (setvar 'osmode 0) (setq ent (car (entsel "\nSelect plex profile: "))) ; (command "_.ZOOM" "object" ent "") (setq dia 0.05) (setq obj (vlax-ename->vla-object ent)) (vla-getboundingbox obj 'Point1 'Point2) (setq point1 (vlax-safearray->list Point1)) (setq point2 (vlax-safearray->list Point2)) (vla-offset obj -0.375) (command "_.explode" "l" "") (foreach ln (vl-remove-if 'listp (mapcar 'cadr (ssnamex (ssget "_W" point1 point2 '((0 . "LINE")))) ) ;_ end of mapcar ) ;_ end of vl-remove-if (command "_.circle" (vlax-curve-getStartPoint ln) dia "_.circle" (vlax-curve-getEndPoint ln) dia ) ;_ end of command ) ;_ end of foreach (command "-overkill" "w" point1 point2 "" "") (setq di ; HOLE SPACING (foreach ln (vl-remove-if 'listp (mapcar 'cadr (ssnamex (ssget "_W" point1 point2 '((0 . "LINE")))) ) ;_ end of mapcar ) ;_ end of vl-remove-if (setq mx (vlax-curve-getdistatparam ln (vlax-curve-getendparam ln)) d0 (- (/ (- mx (* di (fix (/ mx di)))) 2.) di) ) ;_ end of setq (while (and (<= (setq d0 (+ d0 di)) mx) (setq pt (vlax-curve-getpointatdist ln d0)) ) ;_ end of and (entmakex (list (cons 0 "CIRCLE") (cons 10 pt) (cons 40 0.05) (cons 8 "0") ) ;_ end of list ) ;_ end of entmakex ) ;_ end of while ) ;_ end of foreach (setq sset (ssget "_W" point1 point2 '((0 . "LINE")))) (command "_.erase" sset "") (OffsetCircles) (command "_.ZOOM" "p") (setvar 'osmode osn) (vla-endundomark doc) ) ;_ end of defun (vl-load-com) ;| OFFSET CIRCLES|; (defun OffsetCircles (/ clay sset ent obj) (defun *error* (msg) (if (and msg (not (wcmatch (strcase msg t) "*break,*cancel*,*exit*")) ) (princ (strcat "\nError: " msg)) ) (if clay (setvar 'clayer clay) ) (princ) ) ;_ end of defun (setq clay (getvar 'clayer)) (if (not (tblsearch "LAYER" "CNC_DRILL-0.10-PLEX")) (command "-layer" "make" "CNC_DRILL-0.10-PLEX" "color" "T" "255,127,0" "" "") ;_ end of command ) ;_ end of if (if (not (tblsearch "LAYER" "CNC_DRILL-0.30-CNTRSINK")) (command "-layer" "make" "CNC_DRILL-0.30-CNTRSINK" "color" "T" "255,127,159" "" "") ;_ end of command ) ;_ end of if (setvar 'clayer clay) (if (setq sset (ssget "_W" point1 point2 '((0 . "CIRCLE") (40 . 0.05)))) (progn (foreach ent (vl-remove-if 'listp (mapcar 'cadr (ssnamex sset))) (vlax-put-property (vlax-ename->vla-object ent) 'layer "CNC_DRILL-0.10-PLEX" ) ;_ end of vlax-put-property (setq obj (vlax-ename->vla-object ent)) (vla-Offset obj 0.1) (vlax-put-property (vlax-ename->vla-object (entlast)) 'layer "CNC_DRILL-0.30-CNTRSINK" ) ;_ end of vlax-put-property ) ;_ end of foreach ) ;_ end of progn ) ;_ end of if (princ) ) ;_ end of defun Quote
Lee Mac Posted May 23, 2016 Posted May 23, 2016 Am I wrong in thinking that: (vla-offset obj -0.375) would offset the object to the "inside"? The concept of offsetting to the inside or outside using the ActiveX offset method only applies to objects such as arcs, circles & ellipses for which there is a definitive 'inside'. When applied to polylines, the offset direction is dependent on the orientation of the polyline (i.e. clockwise or counter-clockwise). Here is an example demonstrating how to offset to the inside. Quote
PDuMont Posted May 23, 2016 Author Posted May 23, 2016 Thank you Lee. While I am getting OK at cobbling bits and pieces of code together and making them work, your example is well above my pay grade. My selection set will always be a single entity, so I will parse through your code to see if I can apply the process to my lisp... ...that is if you don't mind. Quote
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.