Code Red > AutoLISP (Vanilla / Visual)

Use INSERTOBJ command in Autolisp or equivalent

(1/2) > >>

FELIX:
I want to insert unreferenced images like OLE.
Have an example of INSERTOBJ or an equivalent Autolisp function?

hmspe:
I use code like this.  This is to insert in model space, scaled based on DIMSCALE. 

(defun setpower ()
  (if (null (tblsearch "layer" "power"))
    (command "-layer" "make" "power" "color" "cyan" "power" "")
  )
  (setvar "clayer" "power")
)

(defun enco_insert (symbol / ds)
  (setvar "cmdecho" 0)
  (setpower)
  (setq ds (getvar "dimscale"))
  (prompt "\nSelect insertion point...  ")
  (command "_insert" symbol "PS" ds pause ds ds pause)
  (princ)
)

FELIX:
I need to insert a JPG image and not a block. OK?

MP:
Start with the entmake function if you understand how dictionaries work (e.g. "ACAD_IMAGE_DICT") or the AddRaster method of Paperspace / Modelspace if you prefer the ActiveX route.

MP:
Q & D ...


--- Code: ---(defun _add-raster ( owner image-path point scale rotation / result )
    (if
        (eq 'vla-object
            (type
                (setq result
                    (vl-catch-all-apply
                       'vlax-invoke
                        (list owner 'AddRaster image-path point scale rotation)
                    )
                )
            )
        )                                               
        result
    )
)
--- End code ---


--- Code: ---(setq raster
    (_add-raster
        (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object)))
        "C:\\Users\\MP\\Pictures\\The-Answer-Is-42.png"
        '(0.0 0.0 0.0)
        1.0
        0.0
    )   
)
--- End code ---

Cheers.

Navigation

[0] Message Index

[#] Next page

Go to full version