harinezumi Posted July 18, 2019 Posted July 18, 2019 (edited) I mostly work in 2d, and when something goes out of the z=0 plane (importing something, accidentaly moving the z ucs) thing go wrong. I would like a function that when opening a drawing alerts me if there are point objects with a Z<>0. i know I could use something like Acadoc to load the function opening the file but I don't know how to retrive that information and engage the alert window. Not a programmer, so any help is welcome. Edited July 22, 2019 by harinezumi better explanation Quote
ronjonp Posted July 18, 2019 Posted July 18, 2019 Give this a try: (defun c:foo (/ s) ;; RJP » 2019-07-18 (cond ((setq s (ssget "_X" (list '(0 . "point") '(-4 . "*,*,/=") '(10 0. 0. 0.)))) (sssetfirst nil s) (alert (strcat (itoa (sslength s)) " points are NOT at zero elevation!")) ) ) (princ) ) Quote
tombu Posted July 18, 2019 Posted July 18, 2019 Would setting OSNAPZ to 1 and ELEVATION (0.00 by default) to 0.00 in acaddoc.lsp solve the problems you're having with those drawings? All your snaped points would have an elevation of 0.00. Quote
wkplan Posted July 22, 2019 Posted July 22, 2019 Only points? What about other objects in the drawing? I would check extmin and extmax: (defun c:check_3d (/ FUZZ ZL ZR) (setq fuzz 0.05) ; fuzzy-factor: how close to zero? (setq zl (caddr (getvar 'extmin)) zr (caddr (getvar 'extmax)) ) (cond ((AND (equal zl 0 fuzz) (equal zr 0 fuzz)) (alert "All points/objects at zero \n[within tolerance}") ) ((< zl 0) (alert "Lower left corner is negative")) ((> zl 0) (alert "Lower left corner is positive")) ((< zr 0) (alert "Upper right corner is negative")) ((> zr 0) (alert "Upper right corner is positive")) (t nil) ) (princ) ) (c:check_3d) 1 Quote
harinezumi Posted July 22, 2019 Author Posted July 22, 2019 On 7/18/2019 at 7:35 PM, tombu said: Would setting OSNAPZ to 1 and ELEVATION (0.00 by default) to 0.00 in acaddoc.lsp solve the problems you're having with those drawings? All your snaped points would have an elevation of 0.00. Thank you, I use them but I wuant to be conscious of eventual 3D points Quote
harinezumi Posted July 22, 2019 Author Posted July 22, 2019 On 7/18/2019 at 5:38 PM, ronjonp said: Give this a try: (defun c:foo (/ s) ;; RJP » 2019-07-18 (cond ((setq s (ssget "_X" (list '(0 . "point") '(-4 . "*,*,/=") '(10 0. 0. 0.)))) (sssetfirst nil s) (alert (strcat (itoa (sslength s)) " points are NOT at zero elevation!")) ) ) (princ) ) Sorry I wasn't clear: any element, not points only Quote
harinezumi Posted July 22, 2019 Author Posted July 22, 2019 3 hours ago, wkplan said: Only points? What about other objects in the drawing? I would check extmin and extmax: (defun c:check_3d (/ FUZZ ZL ZR) (setq fuzz 0.05) ; fuzzy-factor: how close to zero? (setq zl (caddr (getvar 'extmin)) zr (caddr (getvar 'extmax)) ) (cond ((AND (equal zl 0 fuzz) (equal zr 0 fuzz)) (alert "All points/objects at zero \n[within tolerance}") ) ((< zl 0) (alert "Lower left corner is negative")) ((> zl 0) (alert "Lower left corner is positive")) ((< zr 0) (alert "Upper right corner is negative")) ((> zr 0) (alert "Upper right corner is positive")) (t nil) ) (princ) ) (c:check_3d) Thank you, why are you using a fuzz? can we check also nanometers, angstom errors? Quote
wkplan Posted July 23, 2019 Posted July 23, 2019 using a fuzzy factor is common pratice. Fuzz makes the test a little bit more tolerant. See here: https://knowledge.autodesk.com/search-result/caas/CloudHelp/cloudhelp/2017/ENU/3PP-ACD-AUTOLISP-WILEY/files/GUID-EC493807-2065-4A1B-A04B-CE7A04126737-htm.html If you don't want a fuzz, just delete it from the equals. Quote
harinezumi Posted July 26, 2019 Author Posted July 26, 2019 I changed it to put the fuzz variable inside the alert but id doesn't work. I guess some very lisp newcomer error. Can you help? (I also tested (getvar 'fuzz) and (getvar "fuzz") ...) ;; source: https://www.cadtutor.net/forum/topic/68249-alert-for-points-with-z0/ (defun c:check3d (/ FUZZ ZL ZR) ; (setq fuzz 0.00005) ; fuzzy-factor: how close to zero? OPTIONAL (setq zl (caddr (getvar 'extmin)) zr (caddr (getvar 'extmax)) ) (cond ((AND (equal zl 0 fuzz) (equal zr 0 fuzz)) (alert (strcat "All points/objects at zero \n[within " (getvar fuzz) " tolerance]" ) ) ) ((< zl 0) (alert "Lower left corner is negative")) ((> zl 0) (alert "Lower left corner is positive")) ((< zr 0) (alert "Upper right corner is negative")) ((> zr 0) (alert "Upper right corner is positive")) (t nil) ) (princ) ) (c:check3d) Quote
wkplan Posted July 28, 2019 Posted July 28, 2019 Two points, getvar will give you information about the requested System-Variable. For example, try changing the settings for osnap, then enter at the console (getvar 'osmode). Since fuzz ist just a simple symbol, which points to the value of a variable named fuzz, "getvar fuzz" will always give an error. BTW: if fuzz would be a existing system-variabe, you would have to quote fuzz or sett it within " " a) (getvar 'fuzz) b) (getvar "fuzz") And second, fuzz holds a "floating" value , such as 0.123 Using floating,or integer, values within a string requires always a conversion, otherwise it will throw an error. Change (strcat "All points/objects at zero \n[within " (getvar fuzz) " tolerance]" ) to (strcat "All points/objects at zero \n[within " (rtos fuzz 2) " tolerance]" ) Please read lisp documentation for the use fo itao and rtos functions. Note that your code requires the setting for fuzz, leaving it blank will also cause an error. regards Wolfgang 1 Quote
harinezumi Posted July 29, 2019 Author Posted July 29, 2019 On 7/28/2019 at 12:03 PM, wkplan said: Two points, […] regards Wolfgang Thank you Wolfgang, it works as I wish. Quote
harinezumi Posted July 31, 2019 Author Posted July 31, 2019 And what about selecting (or highlighting) elements outside the plane z = 0 instead of warning? Thank you Quote
wkplan Posted August 1, 2019 Posted August 1, 2019 I'm not quite shure if a program would really help. There are many reasons for "non-flat"-plans, e.g.: - lines/arcs/3d-polylines with a start or end-point (or both) at z /= 0 - circles/inserts/text/xrefs at z /= 0 - inserts with z = 0, but the block self contains something outside z = 0 - real 3-elements, such als basic volumes or extrusions You an check for all this and highlight these elements, but how to deal with this elements? - change the elements to z=0 could produce double elements, as there may be another element at z=0 still in the drawing (consider "3d-walls" drawn not as a volume) - just delete them could lead to a lack of information, maybee unreadable plans I'm dealing most with floorplans. If i have the suspission that a plan contains "unwanted 3D", i change the point of view to a view from the side and zoom to the extends. Selecting all "over and under" the flat line, i can count this elements with the property window and check what type of object they are. Depending on what an how many scrap is in the drawing, I the can decide to fix it manually ore run a tool to flatten the dwg. regards Wolfgang Quote
harinezumi Posted August 23, 2019 Author Posted August 23, 2019 On 8/1/2019 at 10:28 AM, wkplan said: I'm dealing most with floorplans. If i have the suspission that a plan contains "unwanted 3D", i change the point of view to a view from the side and zoom to the extends. Selecting all "over and under" the flat line, i can count this elements with the property window and check what type of object they are. Depending on what an how many scrap is in the drawing, I the can decide to fix it manually ore run a tool to flatten the dwg. regards Wolfgang I usually do as you say, but sometimes the defect are tiny: lately I had this huge and detailed siteplan in meters with defects of Z in cm - I couldn't see elements out of the plane in a side view, it was a boring zoom in and out, and even when found something seeing it from the side it wasn't easy to understand was that bloody element. Then snaps become a mess (i discovered the defect because I wasn't able to snap to intesection). So I would like to be alerted when opening a file, but then a select "3d objects" would help to fix them. I usually run change->properties->elevation to 0, but this doesn't fix blocks etcetera as you said, a tool to find them wuould help, even to fix them manually. Quote
wkplan Posted August 26, 2019 Posted August 26, 2019 You would need to check for every type of object, e.g. Line, ARC, Circle, Shape and so on. Every object-type has its own way to check for "3D". A lot of coding, because you first need to check what object-type the drawing element is, then decide witch method of checking to use and finally highlight the element, or put it in a selectionset or simply draw a line to the elements base point, or you may whish to correct it by programm. For basic autocad-drawing objects, I found checking with side-views and zoom works good for me. One thing that I would check by programm are block-references (Inserts). The following code work's by determining the bounding box of any drawing object. If Inserts with 3D-content, ore insertion points /= 0 where found, the Blockname is given out. You than can correct the block definition to fix the problem. (defun c:test (/ j k minp maxp) (vl-load-com) ; ITERATE THROUGH THE OBJECTS IN MODEL SPACE (vlax-for object (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object)) ) (setq bbox ; get bounding box (vl-catch-all-apply 'vla-getboundingbox (list object 'j 'k)) ) (if (vl-catch-all-error-p bbox) (princ (strcat "\nCan't determine Bounding box: " (vla-get-objectname object))) (progn (setq zminp (caddr (vlax-safearray->list j))) ; extract z-values (setq zmaxp (caddr (vlax-safearray->list k))) (if (AND(OR (< zminp 0) (> zmaxp 0)) ; Filter: anything that's not flat (wcmatch (vla-get-objectname object) "AcDbBlockReference")) ; Filter: Report only Inserts (princ (strcat "\nObject: " (vla-get-effectivename object) " Z-min: " (rtos zminp) " Z-max: " (rtos zmaxp) ) ) ) ) ) ) (princ "\nDone") ) (c:test) Hope it helps Wolfgang Quote
Roy_043 Posted August 26, 2019 Posted August 26, 2019 There are also two variables: EXTMIN and EXTMAX. Checking if the Z of both variables is zero should work (provided there is at least one entity in the current space). Quote
wkplan Posted August 26, 2019 Posted August 26, 2019 1 hour ago, Roy_043 said: There are also two variables: EXTMIN and EXTMAX. Checking if the Z of both variables is zero should work (provided there is at least one entity in the current space). shure this works. See posting #3 regards Wolfgang 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.