Code Red > AutoLISP (Vanilla / Visual)
Repathing xRefs in AutoCAD for Mac
cmwade77:
I need to be able to change the drive letter in AutoCAD for Mac quickly
I think I have found the tool that I need to make this work properly at http://www.theswamp.org/index.php?topic=7628.msg109153#msg109153
--- Code: ---(defun ChangeXrefDrive (newDrive / xrefEdata)
(mapcar
'(lambda (blockName)
(if
(eq
(logand
4
(cdr (assoc 70 (setq xrefEdata (entget (tblobjname "BLOCK" blockName))))
)
)
4
)
(command "._XREF"
"PATH"
(cdr (assoc 2 xrefEdata))
(strcat newDrive (substr (cdr (assoc 1 xrefEdata)) 3))
)
)
)
(ai_table "BLOCK" 0)
)
(princ)
)
--- End code ---
This problem is ai_table doesn't work in AutoCAD for Mac, I have tried changing it to (entnext), but that doesn't quite work, so I am not sure how to best handle this. Some important notes for those that don't use Macs, anything that would require (vl-load-com) will not work.
Lee Mac:
Just use tblnext to iterate over the Block Table.
irneb:
Just another thing: Mac doesn't have drive letters. It's only windows which has this concept - as it got it from the VMS operating system originally and was propagated through DOS.
OSX is actually a BSD operating system (a derivative of the Unix/Linux world). So a "drive" is actually a "folder" - usually under the /mount system folder. For this reason I'd be inclined to advise you on using relative pathing for your xrefs instead. That way they'd work just fine even if the same DWG is opened in OSX/Win.
Also note that only windows uses backslashes as path delimiters, OSX/Linux uses forward slashes. Though I think ACad translates these correctly, but I have found situations where it causes problems. The strange thing is that an undocumented feature of windows allows you to use forward slashes as well, so I tend to change all backslashes to forward slashes - makes for less backslash escapes in strings also :laugh:
cmwade77:
--- Quote from: irneb on August 04, 2012, 03:05:20 am ---Just another thing: Mac doesn't have drive letters. It's only windows which has this concept - as it got it from the VMS operating system originally and was propagated through DOS.
OSX is actually a BSD operating system (a derivative of the Unix/Linux world). So a "drive" is actually a "folder" - usually under the /mount system folder. For this reason I'd be inclined to advise you on using relative pathing for your xrefs instead. That way they'd work just fine even if the same DWG is opened in OSX/Win.
Also note that only windows uses backslashes as path delimiters, OSX/Linux uses forward slashes. Though I think ACad translates these correctly, but I have found situations where it causes problems. The strange thing is that an undocumented feature of windows allows you to use forward slashes as well, so I tend to change all backslashes to forward slashes - makes for less backslash escapes in strings also :laugh:
--- End quote ---
Yes, we are going to use relative paths in the future; however, there are a lot of projects that we have from before we had a mixed environment that still have hard coded paths that we need to fix.
BlackBox:
Perhaps I overlooked something while skimming this thread, but out of curiosity, why don't you just use Reference Manager? :?
--- Code - Auto/Visual Lisp: ---(vl-load-com) (defun c:REFMAN (/ file) (if (setq file (findfile (strcat (vl-registry-read (strcat "HKEY_LOCAL_MACHINE\\" (if vlax-user-product-key ; If 2013 (vlax-user-product-key) ; Use 2013 function (vlax-product-key) ; Use legacy function ) ) "ACADLOCATION" ) "\\AdRefMan.exe" ) ) ) (startapp "explorer" file) (prompt "\n** File not found ** ") ) (princ))
Navigation
[0] Message Index
[#] Next page
Go to full version