BricsCAD123 Posted June 16, 2020 Posted June 16, 2020 Is there a way I can adjust the code to set the layer the xref is assigned to? Quote
thajmul Posted September 24, 2022 Posted September 24, 2022 1.Batch Detach All Old Xref's using Script Writer WSCRIPT > Use script line: _.open *file* _.xref _D * _.zoom _E _.qsave _.close(i tried also this one.it does not works for me) this script line is not working for me.can anyone help me? _.open *file*"C:\Users\thajmul hussain\desktop\fais\try\Template.dwg" _.xref _D Quote
Lee Mac Posted September 25, 2022 Posted September 25, 2022 What error message do you receive? I would suggest turning on command line logging and then inspect the command line logs for the processed drawings, so that you can understand where the script is failing and adjust the script line accordingly. Quote
thajmul Posted September 27, 2022 Posted September 27, 2022 On 9/26/2022 at 3:20 AM, Lee Mac said: What error message do you receive? I would suggest turning on command line logging and then inspect the command line logs for the processed drawings, so that you can understand where the script is failing and adjust the script line accordingly. hi lee, 1.it does not popup a message in the commandline logging while using this script (_.open *file* _.xref _D * _.zoom _E _.qsave _.close) i attached the image. kindly see the first image.it's blank. 2.i want to know what script line to write for the update path because i have a bunch of drawing to update. kindly see the second image. Quote
thajmul Posted September 27, 2022 Posted September 27, 2022 On 9/26/2022 at 5:13 AM, BIGAL said: Missing a space here *file* "C: hi bigal, i followed your instruction it does not work for me. _.open *file* "C:\Users\thajmul hussain\desktop\rahfa\Revision-test\XREF-TEMPLATE.dwg" _.xref _D is this correct? Quote
BIGAL Posted September 27, 2022 Posted September 27, 2022 I dont know I did not test just found that typo copy and paste 1 command at a time to command line and see what error messages appear. that is your script OPEN your filename 1 _.xref D Quote
thajmul Posted September 27, 2022 Posted September 27, 2022 On 9/26/2022 at 3:20 AM, Lee Mac said: What error message do you receive? I would suggest turning on command line logging and then inspect the command line logs for the processed drawings, so that you can understand where the script is failing and adjust the script line accordingly. hii lee, kindly reply for this message.i am really struggle rectified this .i attached the image kindly see. what i want to write here (_.open *file* _.xref _D XREF-TEMPLATE _.zoom _E _.qsave _.close) thanks advance hussain Quote
thajmul Posted September 27, 2022 Posted September 27, 2022 On 2/6/2019 at 11:24 AM, rlx said: a quicky before breakfast ;;; Attach Xref to all drawings in Folder , RLX 6-Feb-2019 (defun c:RlxFaXref (/ _getfolder app adoc odbs odbx v xref folder dwg xr) (vl-load-com) (defun _getfolder ( m / sh f r ) (setq sh (vla-getinterfaceobject (vlax-get-acad-object) "Shell.Application") f (vlax-invoke-method sh 'browseforfolder 0 m 0)) (vlax-release-object sh)(if f (progn (setq r (vlax-get-property (vlax-get-property f 'self) 'path))(if (wcmatch r "*\\") r (strcat r "\\"))))) ; i is 0 (absolute), 1 (relative) of 2 (no) -xref path (defun RLXref_SetPathType (i) (vl-registry-write (strcat "HKEY_CURRENT_USER\\" (vlax-product-key) "\\Profiles\\" (getvar "cprofile") "\\Dialogs\\XattachDialog") "PathType" i)) (setq odbs "ObjectDBX.AxDbDocument" v (substr (getvar 'acadver) 1 2) adoc (vla-get-activedocument (setq app (vlax-get-acad-object)))) (RLXref_SetPathType 1) (cond ((vl-catch-all-error-p (setq odbx (vl-catch-all-apply 'vla-getinterfaceobject (list app (if (< (atoi v) 16) odbs (strcat odbs "." v)))))) (princ "\nObject DBX interface not created!")) ((not (setq xref (getfiled "Select Xref to attach" "" "dwg" 0))) (alert "No Xref was selected")) ((setq folder (_getfolder "Select folder with drawings to attach xref to")) (foreach dwg (vl-directory-files folder "*.dwg" 0) (setq dwg (strcat folder dwg)) (if (vl-catch-all-error-p (vl-catch-all-apply 'vla-open (list odbx dwg))) (princ (strcase (strcat "\nError opening: " dwg))) (progn (princ (strcat "\nOpening: " dwg)) ; attach xref (if (vl-catch-all-error-p (setq xr (vl-catch-all-apply 'vla-AttachExternalReference (list (vla-get-ModelSpace odbx) xref (vl-filename-base xref) (vlax-3d-point 0 0 0) 1 1 1 0 :vlax-false)))) (princ (vl-catch-all-error-message xr))) ; save drawing (vla-saveas odbx (vla-get-name odbx)) ) ) ) ) ) (princ) ) hi rlx, can you modify your code according to "select new path"? thanks advance Quote
rlx Posted September 27, 2022 Posted September 27, 2022 Hi Thajmul, not sure what you want , you wish to select a folder and then update the xrefpath for all drawings in this folder? Quote
thajmul Posted September 27, 2022 Posted September 27, 2022 1 hour ago, rlx said: Hi Thajmul, not sure what you want , you wish to select a folder and then update the xrefpath for all drawings in this folder? kindly see the image you would like to know. what i am trying to asking.the Xref drawing appear not found and another drawing appears unreferenced Quote
rlx Posted September 27, 2022 Posted September 27, 2022 maybe in the code you should change the xref path type from 1 to 0 ? (RLXref_SetPathType 1) -> (RLXref_SetPathType 0) Quote
thajmul Posted September 27, 2022 Posted September 27, 2022 20 minutes ago, rlx said: maybe in the code you should change the xref path type from 1 to 0 ? (RLXref_SetPathType 1) -> (RLXref_SetPathType 0) hi rlx sorry to ask again. nothing happened.kindly see the image Quote
rlx Posted September 27, 2022 Posted September 27, 2022 (edited) no problem thajmul Apparently the xref you are trying to attach is already in your drawing so you would first have to erase / detach the xref & purge the drawing. Probably best to use a normal script for that because I'm not sure this can all be done with odbx (little out of practice because of murdering workload , but what else is new). Other problem , I mean challenge , is that your (network) paths are unique for your situation making it difficult for someone else to replicate your problem. The routine you use has little error trapping for this , just displaying what the error was. Edited September 27, 2022 by rlx Quote
rlx Posted September 27, 2022 Posted September 27, 2022 Maybe this works to kill of all xrefs ;;; https://www.cadtutor.net/forum/topic/66789-lisp-to-attach-xref-to-multiple-drawings/page/2/#comment-601144 ;;; Detach all Xrefs in all drawings in Folder , RLX 27-Sep-2022 (defun c:RlxOdbxDeleteXref (/ _getfolder dbx_ver app dbxv folder dwg xr) (vl-load-com) (defun _getfolder ( m / sh f r ) (setq sh (vla-getinterfaceobject (vlax-get-acad-object) "Shell.Application") f (vlax-invoke-method sh 'browseforfolder 0 m 0)) (vlax-release-object sh)(if f (progn (setq r (vlax-get-property (vlax-get-property f 'self) 'path))(if (wcmatch r "*\\") r (strcat r "\\"))))) (defun dbx_ver ( / v) (strcat "objectdbx.axdbdocument" (if (< (setq v (atoi (getvar 'acadver))) 16) "" (strcat "." (itoa v))))) (setq app (vlax-get-acad-object) dbxv (dbx_ver)) (cond ((vl-catch-all-error-p (setq odbx (vl-catch-all-apply 'vla-getinterfaceobject (list app dbxv)))) (princ "\nObject DBX interface not created!")) ((setq folder (_getfolder "Select folder with drawings to delete (ALL) xrefs")) (foreach dwg (vl-directory-files folder "*.dwg" 0) (setq dwg (strcat folder dwg)) (if (vl-catch-all-error-p (vl-catch-all-apply 'vla-open (list odbx dwg))) (princ (strcase (strcat "\nError opening: " dwg))) (progn (princ (strcat "\nOpening: " dwg)) ;;; seek & destroy (all) xrefs (vlax-for lt (vla-get-layouts odbx) (vlax-for blkobj (vla-get-block lt) (if (and (eq (vla-get-objectname blkobj) "AcDbBlockReference")(vlax-property-available-p blkobj 'Path)) (vlax-invoke-method blkobj 'Delete) ) ) ) ; save drawing (vla-saveas odbx (vla-get-name odbx)) );end progn );end if ); end foreach ); end setq folder (t (princ "\nComputer says no")) ); end cond (vl-catch-all-apply 'vlax-release-object (list app)) (vl-catch-all-apply 'vlax-release-object (list odbx)) (princ) ) ;;; (c:RlxOdbxDeleteXref) Quote
thajmul Posted September 28, 2022 Posted September 28, 2022 14 hours ago, rlx said: no problem thajmul Apparently the xref you are trying to attach is already in your drawing so you would first have to erase / detach the xref & purge the drawing. Probably best to use a normal script for that because I'm not sure this can all be done with odbx (little out of practice because of murdering workload , but what else is new). Other problem , I mean challenge , is that your (network) paths are unique for your situation making it difficult for someone else to replicate your problem. The routine you use has little error trapping for this , just displaying what the error was. here is the problem i am detaching one by one for my drawing.it is really frustrating. thank you so much your kind reply. Quote
rlx Posted September 28, 2022 Posted September 28, 2022 That's no problem thajmul , I can modify the lisp to only detacht a xref with a specific name so you can enter the name (getstring) or select (getfile) the xref first if you want. Will this name only occur as xref or can it also occur as a regular blockinsert? Quote
thajmul Posted September 28, 2022 Posted September 28, 2022 15 hours ago, rlx said: Maybe this works to kill of all xrefs ;;; https://www.cadtutor.net/forum/topic/66789-lisp-to-attach-xref-to-multiple-drawings/page/2/#comment-601144 ;;; Detach all Xrefs in all drawings in Folder , RLX 27-Sep-2022 (defun c:RlxOdbxDeleteXref (/ _getfolder dbx_ver app dbxv folder dwg xr) (vl-load-com) (defun _getfolder ( m / sh f r ) (setq sh (vla-getinterfaceobject (vlax-get-acad-object) "Shell.Application") f (vlax-invoke-method sh 'browseforfolder 0 m 0)) (vlax-release-object sh)(if f (progn (setq r (vlax-get-property (vlax-get-property f 'self) 'path))(if (wcmatch r "*\\") r (strcat r "\\"))))) (defun dbx_ver ( / v) (strcat "objectdbx.axdbdocument" (if (< (setq v (atoi (getvar 'acadver))) 16) "" (strcat "." (itoa v))))) (setq app (vlax-get-acad-object) dbxv (dbx_ver)) (cond ((vl-catch-all-error-p (setq odbx (vl-catch-all-apply 'vla-getinterfaceobject (list app dbxv)))) (princ "\nObject DBX interface not created!")) ((setq folder (_getfolder "Select folder with drawings to delete (ALL) xrefs")) (foreach dwg (vl-directory-files folder "*.dwg" 0) (setq dwg (strcat folder dwg)) (if (vl-catch-all-error-p (vl-catch-all-apply 'vla-open (list odbx dwg))) (princ (strcase (strcat "\nError opening: " dwg))) (progn (princ (strcat "\nOpening: " dwg)) ;;; seek & destroy (all) xrefs (vlax-for lt (vla-get-layouts odbx) (vlax-for blkobj (vla-get-block lt) (if (and (eq (vla-get-objectname blkobj) "AcDbBlockReference")(vlax-property-available-p blkobj 'Path)) (vlax-invoke-method blkobj 'Delete) ) ) ) ; save drawing (vla-saveas odbx (vla-get-name odbx)) );end progn );end if ); end foreach ); end setq folder (t (princ "\nComputer says no")) ); end cond (vl-catch-all-apply 'vlax-release-object (list app)) (vl-catch-all-apply 'vlax-release-object (list odbx)) (princ) ) ;;; (c:RlxOdbxDeleteXref) hi rlx did you try this lisp in your computer?for my case nothing happened to me. i am using zwcad Quote
thajmul Posted September 28, 2022 Posted September 28, 2022 15 minutes ago, rlx said: That's no problem thajmul , I can modify the lisp to only detacht a xref with a specific name so you can enter the name (getstring) or select (getfile) the xref first if you want. Will this name only occur as xref or can it also occur as a regular blockinsert? where is the modify of lisp? Quote
rlx Posted September 28, 2022 Posted September 28, 2022 (edited) I don't have zwcad and never used it so not sure if its compatible with visual lisp. Maybe there lies your problem because this is mainly a forum for AutoCad. But I tested it on my own system (AutoCad2022) and for me it works. (defun c:RlxOdbxDeleteXref (/ _getfolder dbx_ver app dbxv folder xref-name ) (vl-load-com) (defun _getfolder ( m / sh f r ) (setq sh (vla-getinterfaceobject (vlax-get-acad-object) "Shell.Application") f (vlax-invoke-method sh 'browseforfolder 0 m 0)) (vlax-release-object sh)(if f (progn (setq r (vlax-get-property (vlax-get-property f 'self) 'path))(if (wcmatch r "*\\") r (strcat r "\\"))))) (defun dbx_ver ( / v) (strcat "objectdbx.axdbdocument" (if (< (setq v (atoi (getvar 'acadver))) 16) "" (strcat "." (itoa v))))) (defun void (x) (or (not x) (= "" x) (and (eq 'STR (type x)) (not (vl-remove 32 (vl-string->list x)))))) (setq app (vlax-get-acad-object) dbxv (dbx_ver)) (cond ((void (setq xref-name (getstring "\nEnter name of xref you want to detach : "))) (princ "\nComputer says no : invalid xref name")) ((vl-catch-all-error-p (setq odbx (vl-catch-all-apply 'vla-getinterfaceobject (list app dbxv)))) (princ "\nObject DBX interface not created!")) ((setq folder (_getfolder "Select folder with drawings to delete (ALL) xrefs")) (setq xref-name (strcase xref-name)) (foreach dwg (vl-directory-files folder "*.dwg" 0) (setq dwg (strcat folder dwg)) (if (vl-catch-all-error-p (vl-catch-all-apply 'vla-open (list odbx dwg))) (princ (strcase (strcat "\nError opening: " dwg))) (progn (princ (strcat "\nOpening: " dwg)) ;;; seek & destroy (all) xrefs (vlax-for lt (vla-get-layouts odbx) (vlax-for blkobj (vla-get-block lt) (if (and (eq (vla-get-objectname blkobj) "AcDbBlockReference") (vlax-property-available-p blkobj 'Path) (eq xref-name (strcase (vl-filename-base (vla-get-name blkobj)) t)) ) (vlax-invoke-method blkobj 'Delete) ) ) ) ; save drawing (vla-saveas odbx (vla-get-name odbx)) );end progn );end if (princ "\nDone") ); end foreach ); end setq folder (t (princ "\nComputer says no")) ); end cond (vl-catch-all-apply 'vlax-release-object (list app)) (vl-catch-all-apply 'vlax-release-object (list odbx)) (princ) ) Edited September 28, 2022 by rlx 1 1 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.