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 images via lisp
« previous
next »
Print
Pages: [
1
] |
Go Down
Author
Topic: Edit path type for images via lisp (Read 2074 times)
0 Members and 1 Guest are viewing this topic.
densan
Mosquito
Posts: 12
Edit path type for images via lisp
«
on:
June 11, 2019, 08:32:22 PM »
Hello everyone,
I am trying to find a function to set the path of attached images to NONE. I am familiar with the reference manager tool but I am looking for automation via lisp, as it will be part of a major cleanup process in 1000's of drawings.
Found the following code but it's only removing the path for one image even though the drawing contains multiple images.
I only know basic lisp concepts but I don't understand why the code it's not looping.
Thank you for any help you can offer,
Code - Auto/Visual Lisp:
[Select]
;;;Jeff Mishler, Dec 2, 2004
;;;Removes path from images
(
defun
repath_images
(
/
ss i img iname
)
(
setq
ss
(
ssget
"X"
'
(
(
0
.
"IMAGE"
)
)
)
)
(
setq
i
-
1
)
(
while
(
<
(
setq
i
(
1+
i
)
)
(
sslength
ss
)
)
(
setq
img
(
vlax
-
ename
->
vla-object
(
ssname
ss i
)
)
Iname
(
vla-get-imagefile
img
)
)
(
while
(
vl-string-search
"
\\
"
Iname
)
(
setq
Iname
(
substr
Iname
2
)
)
)
(
vla-put-imagefile
img Iname
)
)
)
Logged
kdub_nz
Mesozoic keyThumper
SuperMod
Water Moccasin
Posts: 2132
class keyThumper<T>:ILazy<T>
Re: Edit path type for images via lisp
«
Reply #1 on:
June 11, 2019, 09:55:19 PM »
Welcome to the swamp.
Jeff's routine works for me.
This is from BricsCAD V19
I can't see anything in the code that would fail and cause your issue in AutoCAD.
Logged
Called Kerry in my other life
Retired; but they dragged me back in !
I live at UTC + 13.00
---
some people complain about loading the dishwasher.
Sometimes the question is more important than the answer.
densan
Mosquito
Posts: 12
Re: Edit path type for images via lisp
«
Reply #2 on:
June 12, 2019, 11:11:09 AM »
Thank you Kdub, I moved the lisp to a trusted location folder and the weird behavior disappeared.
May I ask, what would be the correct way to add an
IF
statement (line 5 in revised code) or a way to process the function if images exist in the drawing.
Code - Auto/Visual Lisp:
[Select]
;;;Jeff Mishler, Dec 2, 2004
;;;Removes path from images
(
defun
c:repath_images
(
/
ss i img iname
)
(
setq
ss
(
ssget
"X"
'
(
(
0
.
"IMAGE"
)
)
)
)
;; (if (/= ss nil) then? <- where to start the IF
(
setq
i
-
1
)
(
while
(
<
(
setq
i
(
1+
i
)
)
(
sslength
ss
)
)
(
setq
img
(
vlax
-
ename
->
vla-object
(
ssname
ss i
)
)
Iname
(
vla-get-imagefile
img
)
)
(
while
(
vl-string-search
"
\\
"
Iname
)
(
setq
Iname
(
substr
Iname
2
)
)
)
(
vla-put-imagefile
img Iname
)
)
)
Logged
ribarm
Gator
Posts: 3255
Marko Ribar, architect
WWW
Re: Edit path type for images via lisp
«
Reply #3 on:
June 12, 2019, 11:27:51 AM »
Code - Auto/Visual Lisp:
[Select]
...
(
if
(
setq
ss
(
ssget
"X"
'
(
(
0
.
"IMAGE"
)
)
)
)
(
progn
...
)
)
...
Just edit line 4 and 5 and add closing ) at the end of (progn ...
Logged
Marko Ribar, d.i.a.
(graduated engineer of architecture)
M.R. on Youtube
Lee Mac
Seagull
Posts: 12912
London, England
WWW
Re: Edit path type for images via lisp
«
Reply #4 on:
June 12, 2019, 01:02:08 PM »
Here's an alternative that will also target unreferenced image xrefs -
Code - Auto/Visual Lisp:
[Select]
(
defun
c:repath_images
(
/
d i x
)
(
if
(
setq
d
(
cdr
(
assoc
-
1
(
dictsearch
(
namedobjdict
)
"acad_image_dict"
)
)
)
)
(
while
(
setq
i
(
dictnext
d
(
not
i
)
)
)
(
if
(
wcmatch
(
cdr
(
setq
x
(
assoc
1
i
)
)
)
"*
\\
*"
)
(
entmod
(
subst
(
cons
1
(
apply
'
strcat
(
cdr
(
fnsplitl
(
cdr
x
)
)
)
)
)
x i
)
)
)
)
)
(
princ
)
)
Logged
Lee Mac Programming
•
Twitter
•
Exchange App Store
densan
Mosquito
Posts: 12
Re: Edit path type for images via lisp
«
Reply #5 on:
June 12, 2019, 03:53:06 PM »
I want to say thank very much to everyone in this post, I appreciate the help and I look forward to continue learning from this great forum.
Logged
Print
Pages: [
1
] |
Go Up
« previous
next »
TheSwamp
»
Code Red
»
AutoLISP (Vanilla / Visual)
»
Topic:
Edit path type for images via lisp