Code Red > AutoLISP (Vanilla / Visual)

Entmake Ole2Frame Paitbrush image

(1/4) > >>

FELIX:
How to create Entmake Ole2Frame Paitbrush image?

MP:
it's challenging to create an ole image via entmake as the image data is stored as hex values in 310 groups (not revealed by entget). The image data is header info - bitmap values - then footer info. None (that I can tell) is documented. The bitmap value are relatively easy to crack but the header, footer info eludes me at present.

So what to do?

Kludegy work arounds include using powerscript to set the clipboard contents (have done before but it's a bit verbose) or a third party utility to perform same. Here is a quick and dirty example of the latter:


--- Code: ---(defun embed-image ( image-path 2d-insert-point / cmdecho elast nircmd-path x y )

    ;;  see: https://www.nirsoft.net/utils/nircmd.html

    (and
        (progn (setq elast (entlast)) t)
        (setq cmdecho (getvar 'cmdecho))
        (setvar 'cmdecho 0)
        (or
            (setq nircmd-path (findfile "nircmd.exe"))
            (setq nircmd-path (findfile "h:\\exe\\nircmd.exe")) ;; set to your installation location
        )
        (setq image-path (findfile image-path))
        (progn
            (startapp nircmd-path (strcat "clipboard copyimage \"" image-path "\""))
            (command ".delay" 500) ;; may have to play with this value
            (command ".pasteclip" (mapcar 'set '(x y) 2d-insert-point))
        )       
    )   
   
    (setvar 'cmdecho cmdecho)
   
    (not (equal elast (entlast)))

)
--- End code ---

e.g.

(embed-image "H:\\sample-image.png" '(0.0 0.0))

<works on my machine>

Cheers.

FELIX:
Very well, it worked.

Now I will continue my program which is replacing referenced images with OLE images so that a DWG drawing file does not require external files when sent.

Replaces NIRCMD.EXE with a lispfunction DLL I made in VB.NET

Thank you very much.

OK.

MP:
Good to hear Felix - you're most welcome.

If you capture the image's dimensions before embedding it (example here) you can set the image size after embedding (it tends to be placed with an arbitrary scale that's a function of the current zoom factor - rarely will it reflect the original image size). Make sure to set the LockAspectRatio property to false before abusing the height and width for them to be accepted as is.

PS: I assume you're going to share your VB code like a good swamper? :)

FELIX:
Image dimensions are easy in .NET environment
It is only now missing the scaled value of the referenced IMAGE entity (in DXF) that will be replaced by the new OLE image.
Can you know the scale value in DXF of the IMAGE object?

Navigation

[0] Message Index

[#] Next page

Go to full version