Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 11/10/2021 in all areas

  1. Using entdel would work though. Using SSGET X will get everything in the drawing. It's that when calling using commands that the selection set gets filtered to the current tab. Entdel or vla-delete will still take care of it. I also had to deal with this problem in my workplace and I came up with some dirty way to go about it though (it wasn't a good practice, but at least good enough to get it working for me). I gave up being very precise, because there's one key factor that I could not yet still solve. One factor you'd still need to check is if the layer is locked or frozen before deleting anything. But the worst factor is checking if you have any blocks that has objects currently using that layer and then purging that block first, and it gets worse with nested blocks. With nested blocks, you need to purge the inner block first before being able to purge the outer one, so finding that sequence (and blocks) matters as well. Otherwise entdel or vla-delete will either yield an error, or won't delete the object, which then the layer won't be deleted. Your DeleteLayer command gave me an idea though... I might try implementing some stuff.
    1 point
  2. Yes, it's possible : ;; change attribute ;; https://www.cadtutor.net/forum/topic/73972-pre-fill-in-getstring/ (defun c:attch ( / LM:vl-setattributevalue adoc att blk tag ) (vl-load-com) (setq adoc (vla-get-activedocument (vlax-get-acad-object))) ;; Set Attribute Value - Lee Mac ;; Sets the value of the first attribute with the given tag found within the block, if present. ;; blk - [vla] VLA Block Reference Object ;; tag - [str] Attribute TagString ;; val - [str] Attribute Value ;; Returns: [str] Attribute value if successful, else nil. (defun LM:vl-setattributevalue ( blk tag val ) (setq tag (strcase tag)) (vl-some (function (lambda ( att ) (if (= tag (strcase (vla-get-tagstring att))) (progn (vla-put-textstring att val) val) ) ) ) (vlax-invoke blk 'getattributes) ) ) (while (setq att (car (nentsel "\n select attribute to change: "))) (setq blk (cdr (assoc 330 (entget att)))) ;; get parent block of a nentsel (setq tag (cdr (assoc 2 (entget att)))) (princ tag) (vla-sendcommand adoc "new_value_") ;; this is the trick to add predefined prefix to (getstring) specification that follows... (LM:vl-setattributevalue (vlax-ename->vla-object blk) tag (getstring T "\nNew value : ")) ) (princ) ) HTH. M.R.
    1 point
  3. If you are using nonassociative dimensions, and dimensioning in Paperspace, as I do. Go into MODIFY for your Dimstyle, and check on your FIT tab. I believe you want it as shown in the screenshot. Specifically the Scale for dimension features, select use overall scale of 1.
    1 point
  4. Here, I've coded (c:quickmeasure) tool so that it can be used in any version of AutoCAD/BricsCAD... For now you'll have to be satisfied and with this functionality - it uses ordinary (grread) with no GrSnap implemented - even built-in command IMHO don't have this supported and beside this, how would you see changes if OSNAPs are functioning... Nevermind, if there are more time, perhaps someone may chime in like Mr. Lee Mac (once I got critics from him for using GrSnap, so maybe author himself would do implementation)... (defun c:quickmeasure ( / *error* screenbb car-sort processdir ss ray gr r pt rr txt txtl cmde dimtih dimtxt dimlunit ) (vl-load-com) (defun *error* ( m ) (redraw) (foreach tt txtl (if (and (cadr tt) (not (vlax-erased-p (cadr tt)))) (entdel (cadr tt)) ) ) (if (and ray (not (vlax-erased-p ray))) (entdel ray) ) (command-s "_.UNDO" "_E") (if (and cmde dimtih dimtxt dimlunit) (mapcar (function setvar) '(cmdecho dimtih dimtxt dimlunit) (list cmde dimtih dimtxt dimlunit)) ) (if m (prompt m) ) (princ) ) (defun screenbb ( / w h scz vsz vc ) (setq w (* (car (setq scz (getvar 'screensize))) (/ (setq vsz (getvar 'viewsize)) (cadr scz))) h vsz ) (list (list (- (car (setq vc (getvar 'viewctr))) (/ w 2.0)) (- (cadr vc) (/ h 2.0))) (list (+ (car vc) (/ w 2.0)) (+ (cadr vc) (/ h 2.0)))) ) (defun car-sort ( lst cmp / rtn ) (setq rtn (car lst)) (foreach itm (cdr lst) (if (apply cmp (list itm rtn)) (setq rtn itm) ) ) rtn ) (defun processdir ( ss pt dir / intpt ss elst e r ) (defun intpt ( pt dir e / r x rr ) (setq r (vlax-invoke (vlax-ename->vla-object ray) 'intersectwith (vlax-ename->vla-object e) acextendnone)) (repeat (/ (length r) 3) (setq x (list (car r) (cadr r) (caddr r))) (setq rr (cons x rr)) (setq r (cdddr r)) ) (car-sort rr (function (lambda ( a b ) (< (distance pt a) (distance pt b))))) ) (setq ray (entmakex (list (cons 0 "RAY") (cons 100 "AcDbEntity") (cons 100 "AcDbRay") (cons 10 pt) (cons 11 (append dir (list 0.0)))))) (if ss (progn (setq elst (vl-remove-if (function (lambda ( x ) (null (intpt pt dir x)))) (vl-remove-if-not (function (lambda ( x / catch ) (and (setq catch (vl-catch-all-apply (function vlax-curve-getstartpoint) (list x))) (not (vl-catch-all-error-p catch))))) (vl-remove-if (function listp) (mapcar (function cadr) (ssnamex ss)))))) (if elst (setq e (car-sort elst (function (lambda ( a b ) (< (distance pt (intpt pt dir a)) (distance pt (intpt pt dir b))))))) ) (if e (setq r (list (setq pp (intpt pt dir e)) (distance pt pp))) ) ) ) (entdel ray) r ) (setq cmde (getvar 'cmdecho)) (setvar 'cmdecho 0) (if (= 8 (logand 8 (getvar 'undoctl))) (vl-cmdf "_.UNDO" "_E") ) (vl-cmdf "_.UNDO" "_G") (setq ss (ssget "_A" '((0 . "~VIEWPORT")))) (while (= 5 (car (setq gr (grread t)))) (redraw) (foreach dir (list (list 1.0 0.0) (list -1.0 0.0) (list 0.0 1.0) (list 0.0 -1.0)) (setq r (processdir ss (setq pt (cadr gr)) dir)) (if (and r (not (equal r rr 1e-6))) (progn (grdraw pt (car r) 3 0) (if (setq txt (cadr (assoc dir txtl))) (entupd (cdr (assoc -1 (entmod (subst (cons 1 (rtos (cadr r) 2 6)) (assoc 1 (setq txtx (entget txt))) (subst (cons 10 (mapcar (function (lambda ( a b ) (/ (+ a b) 2.0))) pt (car r))) (assoc 10 txtx) (subst (cons 11 (mapcar (function (lambda ( a b ) (/ (+ a b) 2.0))) pt (car r))) (assoc 11 txtx) txtx))))))) (setq txt (entmakex (list (cons 0 "TEXT") (cons 100 "AcDbEntity") (cons 100 "AcDbText") (cons 10 (mapcar (function (lambda ( a b ) (/ (+ a b) 2.0))) pt (car r))) (cons 11 (mapcar (function (lambda ( a b ) (/ (+ a b) 2.0))) pt (car r))) (cons 50 (if (zerop (cadr dir)) 0.0 (* 0.5 pi))) (cons 40 (* 10.0 (/ (getvar 'viewsize) (cadr (getvar 'screensize))))) (cons 1 (rtos (cadr r) 2 6)) (cons 71 0) (cons 72 1) (cons 73 2)))) ) (if (not (vl-position (list dir txt) txtl)) (setq txtl (cons (list dir txt) txtl)) ) ) (if (null r) (if (and (setq txt (cadr (assoc dir txtl))) (not (vlax-erased-p txt))) (progn (entdel txt) (setq txtl (vl-remove (assoc dir txtl) txtl)) ) ) ) ) (setq rr r) ) ) (foreach tt txtl (if (and (cadr tt) (not (vlax-erased-p (cadr tt)))) (entdel (cadr tt)) ) ) (if (= (car gr) 3) (progn (setq dimtih (getvar 'dimtih)) (setq dimtxt (getvar 'dimtxt)) (setq dimlunit (getvar 'dimlunit)) (setvar 'dimtih 0) (setvar 'dimtxt (* 10.0 (/ (getvar 'viewsize) (cadr (getvar 'screensize))))) (setvar 'dimlunit 6) (setq pt (cadr (grread t))) (foreach dir (list (list 1.0 0.0) (list -1.0 0.0) (list 0.0 1.0) (list 0.0 -1.0)) (setq r (processdir ss pt dir)) (if r (vl-cmdf "_.DIMLINEAR" "_non" pt "_non" (car r) (if (or (equal dir (list 1.0 0.0)) (equal dir (list -1.0 0.0))) "_H" "_V") "_non" (mapcar (function (lambda ( a b ) (/ (+ a b) 2.0))) pt (car r))) ) ) ) ) (*error* nil) ) HTH. M.R.
    1 point
  5. This should help you although some of your request is not understandable :
    1 point
  6. It is simple to remove the unwanted scales and to stop it from continuing. Type the command OBJECTSCALE. You will see a prompt to select annotative object(s). After one or more is selected, a dialog box will pop up where you can both delete the unwanted scales and add others at the same time. If you have not changed the value of PICKFIRST to something greater than zero, you can select the objects before executing the command. To stop the scales from being added automatically, set the system variable, ANNOAUTOSCALE to 0 (zero) and watch out for the toggle buttons on the task bar with the Annotate Icon on them. Hitting the wrong one leads to this sort of inconvenience. I think the default is to add them. I don't remember. I threw the switch to OFF in 2007 when I started using annotative objects. I do keep one of the annotative toggles set to on, ANNOALLVISIBLE which shows all annotative objects at all scales in modelspace whether they match the current annotative scale or not. (They don't plot that way) It works for me because I try and keep only one scale assigned to each of my annotation objects which will be the one current in the viewport they go to. You can get to the add/delete annotative dialog box another way. On the Annotate tab of the ribbon at the far right is a selection for it. You can select multiple annotative objects at once to perform this task and fix them all at once. Only select objects which are to be all assigned to the same scale together. There is no provision to have your resulting efforts assigned different single scales at the same time during one execution of the command and dialog box. Basically just select objects that you want to be set to the same scale. Of course you can assign more than one scale to ALL of the selected objects at the same time using OBJECTSCALE, but right now that is not what we are trying to do. There are a couple of serious pitfalls to watch out for when adding or removing scales from multiple annotative objects at once. A serious error happens if you select non-annotative objects along with annotative objects. Apparently the program code does not separate out the non annotative stuff. Up until version 2019 I am sure, AutoCAD crashes abruptly on an unhandled error condition apparently caused by the non-anno things. In version 2021, the error still occurs but the program does not always crash. A crash occurs without ANY warning or error message if you LAYISO your annotative stuff and select them with a window that includes anything on one or more locked layers. As soon as you click OK in the Add/Remove dialog, the program disappears. Apparently the locked layers are not programmed for. In all cases where the program crashes, you lose work back to the last autosave at least and maybe back to the last hard save.
    1 point
  7. The Apostrophe and the Quote Function I've just uploaded this tutorial to my site to provide a detailed and hopefully comprehensible explanation of the behaviour & purpose of the apostrophe & equivalent quote function in AutoLISP. Any & all feedback is very much appreciated, including anything in the tutorial that may be unclear. I hope this helps, Lee
    1 point
×
×
  • Create New...