Welcome,
Guest
. Please
login
or
register
.
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
News:
Home
Help
Login
Register
TheSwamp
»
Code Red
»
AutoLISP (Vanilla / Visual)
»
Topic:
Edit path type for xrefs via lisp
« previous
next »
Print
Pages: [
1
] |
Go Down
Author
Topic: Edit path type for xrefs via lisp (Read 3564 times)
0 Members and 1 Guest are viewing this topic.
densan
Mosquito
Posts: 12
Edit path type for xrefs via lisp
«
on:
June 20, 2019, 01:33:10 PM »
Hello, I need some help understanding what to edit in the code below.
I have to set the path of attached xrefs to NONE (familiar with reference manager tool, lisp needed for automation purposes).
If I want to set the xref path type to none, do I still need Lee's function section?
It cannot be as simple as to edit line 16, rigth?
It doesn't have to be this code in particular, but looking through various forums and testing multiple sets of code, this one was the closest to what I need.
Any help would be appreciated, thank you.
Code - Auto/Visual Lisp:
[Select]
;; https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/xref-relative-path-lisp/td-p/4792859
;; Changes xref path types from absolute to relative
;; Functions by:
;; Henrique Moreira da Silva - 2014
;; Lee Mac - 2011
;;
;;
(
defun
c:rpath
(
/
)
(
vlax-For
blk
(
vla-Get-Blocks
(
vla-Get-ActiveDocument
(
vlax-Get-Acad-Object
)
)
)
(
if
(
and
(
=
(
vla-Get-IsXref
blk
)
:vlax-True
)
(
/=
(
vl-string-search
"."
(
vla-get-path
blk
)
)
0
)
)
(
vla-put-path
blk
(
LM:XRef:Full
->
Relative
(
vl-string-right-trim
"
\\
"
(
getvar
'DWGPREFIX
)
)
<-
use
"dwgname"
in this line?
(
vla-get-path
blk
)
)
)
)
)
(
vl-cmdf
"_.qsave"
)
(
princ
)
)
;;-------------=={ Full Path to Relative Path }==-------------;;
;; ;;
;; Converts a Full XRef path to a Relative Path. ;;
;;------------------------------------------------------------;;
;; Author: Lee Mac, Copyright © 2011 - www.lee-mac.com ;;
;;------------------------------------------------------------;;
;; Arguments: ;;
;; dir - Directory of the Drawing in which the Xref resides ;;
;; path - Full Xref Path ;;
;;------------------------------------------------------------;;
;; Returns: Relative XRef Path ;;
;;------------------------------------------------------------;;
(
defun
LM:XRef:Full
->
Relative
(
dir path
/
p q
)
(
setq
dir
(
vl-string-right-trim
"
\\
"
dir
)
)
(
cond
(
(
and
(
setq
p
(
vl-string-position
58
dir
)
)
(
setq
q
(
vl-string-position
58
path
)
)
(
not
(
eq
(
strcase
(
substr
dir
1
p
)
)
(
strcase
(
substr
path
1
q
)
)
)
)
)
path
)
(
(
and
(
setq
p
(
vl-string-position
92
dir
)
)
(
setq
q
(
vl-string-position
92
path
)
)
(
eq
(
strcase
(
substr
dir
1
p
)
)
(
strcase
(
substr
path
1
q
)
)
)
)
(
LM:Xref:Full
->
Relative
(
substr
dir
(
+
2
p
)
)
(
substr
path
(
+
2
q
)
)
)
)
(
(
and
(
setq
q
(
vl-string-position
92
path
)
)
(
eq
(
strcase
dir
)
(
strcase
(
substr
path
1
q
)
)
)
)
(
strcat
".
\\
"
(
substr
path
(
+
2
q
)
)
)
)
(
(
eq
""
dir
)
path
)
(
(
setq
p
(
vl-string-position
92
dir
)
)
(
LM:Xref:Full
->
Relative
(
substr
dir
(
+
2
p
)
)
(
strcat
"..
\\
"
path
)
)
)
(
(
LM:Xref:Full
->
Relative
""
(
strcat
"..
\\
"
path
)
)
)
)
)
Logged
Lee Mac
Seagull
Posts: 12915
London, England
WWW
Re: Edit path type for xrefs via lisp
«
Reply #1 on:
June 20, 2019, 02:45:31 PM »
This should be sufficient -
Code - Auto/Visual Lisp:
[Select]
(
defun
c:xrnone
(
)
(
vlax-for
b
(
vla-get-blocks
(
vla-get-activedocument
(
vlax-get-acad-object
)
)
)
(
if
(
=
:vlax-true
(
vla-get-isxref
b
)
)
(
vla-put-path
b
(
apply
'
strcat
(
cdr
(
fnsplitl
(
vla-get-path
b
)
)
)
)
)
)
)
(
princ
)
)
(
vl-load-com
)
(
princ
)
Logged
Lee Mac Programming
•
Twitter
•
Exchange App Store
densan
Mosquito
Posts: 12
Re: Edit path type for xrefs via lisp
«
Reply #2 on:
June 20, 2019, 04:13:23 PM »
There are not enough thanks to Lee for all the help.
I now know the answer to my question.
...(apply 'strcat (cdr (fnsplitl (vla-get-path b))))...
;; pass all but first item from fnsplitl (....
Thank you very much
Logged
Lee Mac
Seagull
Posts: 12915
London, England
WWW
Re: Edit path type for xrefs via lisp
«
Reply #3 on:
June 20, 2019, 04:31:11 PM »
Precisely
You're most welcome.
Logged
Lee Mac Programming
•
Twitter
•
Exchange App Store
Print
Pages: [
1
] |
Go Up
« previous
next »
TheSwamp
»
Code Red
»
AutoLISP (Vanilla / Visual)
»
Topic:
Edit path type for xrefs via lisp