Attach image with alias name like how -XREF can using -IMAGE

Attach image with alias name like how -XREF can using -IMAGE

JamesMaeding
Advisor Advisor
244 Views
1 Reply
Message 1 of 2

Attach image with alias name like how -XREF can using -IMAGE

JamesMaeding
Advisor
Advisor

If you have two images with same name, but different folders, you run into a problem when attaching using -IMAGE where the second one fails. Its because the alias name is the same as the first.

If you do this with regular dialog box commands like IMAGE, it automatically adds a "_1" at the end to avoid the problem.

I have tools that attach images using a typical world file, just in regular acad, no map or civil3d needed.

They fail on images of the same name though, and you must adjust the other image aliases by hand to "make room" for the next one.

 

Anyway, I want something like this to work:

(COMMAND "-Image" "Test=D:\\Volume Projects\\Grid Volume Surface Prop vs Exist.png" "0,0" "1" "" "0")

That works with -XREF.

I know how to modify the name after its attached, in lisp, activex, .net...all APIs but the image must be attached first with default name and that is the problem.

Any Ideas?

thx


internal protected virtual unsafe Human() : mostlyHarmless
I'm just here for the Shelties

0 Likes
Accepted solutions (1)
245 Views
1 Reply
Reply (1)
Message 2 of 2

JamesMaeding
Advisor
Advisor
Accepted solution

I stumbled upon the answer.

When you use -IMAGE, it uses the filename as the default alias which is no good.

If you use activeX, it uses some odd numbered name as the alias, which seems to never be a duplicate.

This is same image brought in twice using activex:

JamesMaeding_0-1711490261493.png

Then I construct the alias I would have wanted, which is filename with no spaces, and add a 1 or 2 and so on until I get a unique name.

I almost missed this gem, but was messing with activex to set background transparency for tif and png.

So I was able to fix both the duplicate alias issue, setting background transparency, and the code works for both acad and bricscad.

Bricscad uses -IMAGEATTACH instead of -IMAGE but activex code is same for both.

The relevant code part looks like this:

(setq  inimage
         (vlax-invoke
            (vlax-get (vla-get-ActiveLayout (vla-get-activedocument  (vlax-get-acad-object)))
              'Block
            )
            'AddRaster
            TIFFILE
            '(-10000.0 -10000.0 0.0)
            1.0      ;scale
            0.0
         )
  )
  (vla-put-name inimage ALIAS)
  ;IF PNG OR TIF, DO BACKGROUND TRANSPARENCY
  (IF (OR (= WLDEXT ".TIF")
          (= WLDEXT ".PNG")
      )
    (vla-put-transparency inimage -1)
  )
  (vla-update inimage)

 


internal protected virtual unsafe Human() : mostlyHarmless
I'm just here for the Shelties

0 Likes