yrnomad Posted November 1, 2017 Posted November 1, 2017 We are getting errors as we enter AutoCAD since we upgraded to 2018 (I think). I think I've narrowed it down to on routine loaded called XBTF.lsp in our Acad.lsp The goal of this routine is when opening a drawing: to unlock layer E-ANNO-REFR move all xrefs to the back move all text to the front re-lock layer E-ANNO-REFR So, when I open a drawing with this layer in it, we get this message: Opening an AutoCAD 2013/LT 2013 format file.Regenerating model. Press ENTER to continue: -LAYER unlock e-anno-refr ; error: bad argument type: lselsetp nil AutoCAD menu utilities loaded.*Cancel* Command: Autodesk DWG. This file is a TrustedDWG last saved by an Autodesk application or Autodesk licensed application. Command: Command: modemacro Enter new value for MODEMACRO, or . for none : DimSc=$(getvar,dimscale) | LtSc=$(getvar,ltscale) | TxtSz=$(getvar,textsize) Command: When I open a drawing without the layer, we get this one: Opening an AutoCAD 2013/LT 2013 format file.Regenerating model. -LAYER unlock e-anno-refr _draworder _Back *Invalid selection* Expects a point or Window/Last/Crossing/BOX/ALL/Fence/WPolygon/CPolygon/Group/Add/Remove/Multiple/Previous/Undo/AUto/SIngle ; error: Function cancelled AutoCAD menu utilities loaded.*Cancel* *Cancel* Command: Autodesk DWG. This file is a TrustedDWG last saved by an Autodesk application or Autodesk licensed application. Command: Command: modemacro Enter new value for MODEMACRO, or . for none : DimSc=$(getvar,dimscale) | LtSc=$(getvar,ltscale) | TxtSz=$(getvar,textsize) Command: This is XBTF.lsp ;;;Xref to back, text to front;;; (setvar "cmdecho" 1) (COMMAND "-LAYER" "unlock" "e-anno-refr" "") (vl-load-com) (setq selset (ssget "x" '((0 . "INSERT"))) SelToSend selset) (repeat (setq i (sslength selset)) (if (equal (vla-get-IsXRef (vla-item (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))) (vla-get-effectivename (vlax-ename->vla-object (setq ent (ssname selset (setq i (1- i)))))) ) ) :vlax-false ) (setq SelToSend (ssdel ent SelToSend)) ) ) (sssetfirst nil SelToSend) (command "_draworder" "_Back") (COMMAND "-LAYER" "lock" "e-anno-refr" "") (command "texttofront" "all") Quote
Tharwat Posted November 1, 2017 Posted November 1, 2017 (edited) Hi, Try this untested codes and let me know. (defun xref2back (/ str blk sel fnd ) ;; Tharwat - Date: 01.Nov.2017 ;; (or (= (getvar 'CMDECHO) 1) (setvar 'CMDECHO 1)) (and (setq fnd (tblsearch "LAYER" "e-anno-refr")) (command "-LAYER" "unlock" "e-anno-refr" "")) (setq str "") (while (setq blk (tblnext "BLOCK" (not blk))) (if (cdr (assoc 1 blk)) (setq str (strcat str (cdr (assoc 2 blk)) ",")) ) ) (and (setq sel (ssget "_X" (list '(0 . "INSERT") (cons 2 str)))) (sssetfirst nil sel) (command "_draworder" "_Back")) (and fnd (command "-LAYER" "lock" "e-anno-refr" "")) (command "texttofront" "all") (princ) ) ;; The following is to invoke the function without user's intervention. (xref2back) Edited November 1, 2017 by Tharwat Quote
ronjonp Posted November 1, 2017 Posted November 1, 2017 (edited) I use one called 'XRB' ( xref to back ) .. quickly modified to send text to front too. You also don't need to unlock layers when calling draworder. (defun c:xrb (/ b n sp tx) (setvar 'cmdecho 0) (setq sp (vlax-get (vla-get-activedocument (vlax-get-acad-object)) (if (= (getvar 'cvport) 1) 'paperspace 'modelspace ) ) ) (setq b (ssadd)) (setq tx (ssadd)) (vlax-for o sp (setq n (vla-get-objectname o)) (cond ((and (= "AcDbBlockReference" n) (vlax-property-available-p o 'path)) (setq b (ssadd (vlax-vla-object->ename o) b)) ) ((wcmatch n "AcDb*Text,*Dimension*,*Leader*") (setq tx (ssadd (vlax-vla-object->ename o) tx)) ) ) ) (and (> (sslength b) 0) (command "_.draworder" b "" "Back")) (and (> (sslength tx) 0) (command "_.draworder" tx "" "Front")) (setvar 'cmdecho 1) (princ) ) (vl-load-com) @ Tharwat This line will always return T (and (sssetfirst nil (ssget "_X" (list '(0 . "INSERT") (cons 2 str))))) Edited November 1, 2017 by ronjonp *Edit to work in paperspace too Quote
Tharwat Posted November 1, 2017 Posted November 1, 2017 @ Tharwat This line will always return T (and (sssetfirst nil (ssget "_X" (list '(0 . "INSERT") (cons 2 str))))) You are right ronjonp, Thank you. Codes modified. Quote
yrnomad Posted November 1, 2017 Author Posted November 1, 2017 Ok, thanks. To clarify the big picture. Our original routine was thrown together in a hurry to counter a problem we were having with plotting a specific project. The titleblock for that project was provided by the architect, and they used a solid hatch behind the sheet number in their titleblock. So, when we referenced in the titleblock and whatever happens with autocad and draworder with xrefs... the titleblock hatch would obliterate the sheet number. So, between checking both of your out and running a batchplot of 20 sheets... Tharwat, it looks like the code replacement you give take care of the errors, and still print ok. RonJonP, something must be missing for for that part of the function, because with yours, the batchplot came out with the hatch dominant. So, I'll just stick with Tharwat's. But I'm wondering, in the grand scheme of things if I should have in that process had the routine start in tilemode 1, then switch to tilemode 0 and repeat. Just to insure it happens before plotting the layout. What do you guys think? Quote
ronjonp Posted November 2, 2017 Posted November 2, 2017 Ok, thanks..... So, I'll just stick with Tharwat's. But I'm wondering, in the grand scheme of things if I should have in that process had the routine start in tilemode 1, then switch to tilemode 0 and repeat. Just to insure it happens before plotting the layout. What do you guys think? Give this a try .. should accomplish what you're looking for. (defun c:xrb (/ bl ed n tbl tx) (vlax-for a (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))) (if (and (= -1 (vlax-get a 'islayout)) (setq ed (vla-getextensiondictionary a)) (setq tbl (vla-addobject ed "Acad_Sortents" "AcDbSortentsTable")) ) (progn (vlax-for b a (setq n (vla-get-objectname b)) (cond ((and (= "AcDbBlockReference" n) (vlax-property-available-p b 'path)) (setq bl (cons b bl)) ) ((wcmatch n "AcDb*Text,*Dimension*,*Leader*") (setq tx (cons b tx))) ) ) (and bl (vl-catch-all-apply 'vlax-invoke (list tbl 'movetobottom bl))) (and tx (vl-catch-all-apply 'vlax-invoke (list tbl 'movetotop tx))) (mapcar 'set '(bl tx) '(nil nil)) ) ) ) (vla-update (vlax-get-acad-object)) (princ) ) (vl-load-com) 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.