TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: FELIX on August 16, 2019, 11:51:25 AM
-
I want to insert unreferenced images like OLE.
Have an example of INSERTOBJ or an equivalent Autolisp function?
-
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)
)
-
I need to insert a JPG image and not a block. OK?
-
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.
-
Q & D ...
(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
)
)
(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
)
)
Cheers.
-
The program worked but as a referenced image. This I already have. What I need is that it is "OLE2FRAME" "so when you have one or more files the DWG file will not be dependent on many external files.
If you can adapt this program optimally if you do not use "ENTMAKE" it should be the solution.