Jump to content

Entmakex on AutoCAD 2025


Recommended Posts

Posted

I have an AutoLisp program that uses the Entmakex function to create a non-graphical object.
Everything was fine until a few days ago, when I installed AutoCAD 2025.1.1.
The program stopped working and it took me a while to understand that the Entmakex function was the cause.
I looked around the net and found something similar for Autocad LT, which has restrictions on the use of Entmakex.
From what little I understood, Entmakex from Autocad 2025 behaves as if it were AutoCAD LT.
Any ideas?
I discovered the AutoCAD LT problem in this way: someone reported the bug and AutoDesk replied: it's not a bug, we did it on purpose for the LT version. (Why,  I wonder)
OK, but what about the full version?
 
https://help.autodesk.com/view/ACDLT/2024/ENU/?guid=GUID-3F9A2EB2-082D-49DD-8EFD-DAD8F6E9AA6A
 
https://help.autodesk.com/view/ACDLT/2024/ENU/?guid=GUID-1197B695-C73C-4B4D-AD5D-8F8EB64FB253

 

Thank for help

Riccardo
 

EntmakeX.Png

Posted
1 hour ago, BIGAL said:

What are you making ?

 

Thanks for the reply

I am inserting images into a DWG
Using Entmakex (I prefer this to commad+imageattach)
Autocad 2022 works well
Autocad 2025.1.1 crashes with "error: bad argument type: lentityp nil"

This is the code:

(dictadd
  (namedobjdict)
  "ACAD_IMAGE_DICT"
  (entmakex
    (list
      (cons 0 "DICTIONARY")
      (cons 100 "AcDbDictionary")
      (cons 280 0)
      (cons 281 1)
    ) ;; list
  ) ;; entmakex
) ;; dictadd

 

I understand that Entmakex returns "nil" instead of creating a non-graphic entity

 

Thank you for any further help you can give me.

Riccardo

Posted (edited)

This may be an alternative I used it to insert 100+ images.

 

(vla-AddRaster mspace name inspt 1.5 0.0) 

 

 

 

Edited by BIGAL
Posted (edited)

I took the source from a forum, posted way back in 2008, by "T.Willey"

http://www.theswamp.org/index.php?topic=23762.new

Some time ago I had modified and integrated it, for this occasion, always on the same basis as the 2008 post.

I wrote a test program "Test-Image.Lsp", please try it
 

;; -------------------------------------------------------------------
;; Most of below source found at:
;; http://www.theswamp.org/index.php?topic=23762.new
;; -------------------------------------------------------------------
 (defun MyImage (ImPath ImInsPt LatoX
                 / ImDict ImDef Im tempEnt ReactData
                   tempData EndList StartList
                   Imname LatoY TmpList TmpMake
                   Pixellist Rpixel Xpixel Ypixel
                )
  (setq ImName (vl-filename-base ImPath))
  (setq ImDict
    (if (setq tempData (dictsearch (namedobjdict) "ACAD_IMAGE_DICT"))
      (cdr (assoc -1 tempData))
      (dictadd
        (namedobjdict)
        "ACAD_IMAGE_DICT"
        (entmakex
          (list
            (cons 0 "DICTIONARY")
            (cons 100 "AcDbDictionary")
            (cons 280 0)
            (cons 281 1)
          ) ;; list
        ) ;; entmakex
      ) ;; dictadd
    ) ;; if
  ) ;; setq ImDict
  (setq TmpList
      (list
          (cons 0 "IMAGEDEF")
          (cons 100 "AcDbRasterImageDef")
          (cons 1 ImPath)
          (cons 280 1)
          (cons 281 (if (equal (getvar 'Measurement) 0)
                      5 ;; if equal
                      1 ;; else equal
                     ) ;; if
          ) ;; cons 281
      ) ;; list
  ) ;; setq
  ;;
  ;; AutoCAD 2025 bug?
  ;;
  (setq TmpMake (entmakex TmpList)) ;; This line
  ;;
  ;; AutoCAD 2022 gives an Entity
  ;; and program ends successfully
  ;;
  ;; AutoCAD 2025 gives nil
  ;; and program crashes on the next line with
  ;; "error: bad argument type: lentityp nil"
  ;;
  ;; AutoCAD 2025 bug?
  ;;
  (setq ImDef
   (dictadd
     ImDict
     ImName
     TmpMake
   ) ;; dictadd
  ) ;; setq
  (setq PixelList (cdr (assoc 10 (entget ImDef))))
  (setq XPixel (nth 0 PixelList))
  (setq YPixel (nth 1 PixelList))
  (setq RPixel (/ XPixel YPixel))
  (setq LatoY  (/ LatoX RPixel))
  (setq Im
   (entmake
    (list
      (cons 0 "IMAGE")
      (cons 100 "AcDbEntity")
      (cons 8  "IMAGE-RASTER") ;; Layer
      (cons 100 "AcDbRasterImage")
      (cons 10 ImInsPt)
      (list 11 (/ LatoX XPixel) 0.0 0.0) ;; Scala X
      (list 12 0.0 (/ LatoY YPixel) 0.0) ;; Scala Y
      (cons 340 ImDef)
      (cons 70 15)
      (cons 280 0)
      (cons 281 50)
      (cons 282 50)
      (cons 283 0)
      (cons 360 (entmakex
                  (list
                    (cons 0 "IMAGEDEF_REACTOR")
                    (cons 100 "AcDbRasterImageDefReactor")
                  ) ;; // list
                ) ;; entmakex
      ) ;; cons 360
    ) ;; list
   ) ;; entmake
  ) ;; setq Im
  (setq ReactData (entget (cdr (assoc 360 (entget (setq tempEnt (entlast)))))))
  (entmod (subst
             (cons 330 tempEnt)
             (assoc 330 ReactData)
             ReactData
           ) ;; subst
  ) ;; entmod
  (setq tempData (entget ImDef))
  (setq EndList (cdr (member (setq tempList (assoc 330 tempData)) tempData)))
  (setq StartList (reverse (cdr (member (car EndList) (reverse tempData)))))
  (entmod (append
             StartList
             (list (cons 330 (cdr (assoc 360 (entget tempEnt)))))
             EndList
           ) ;; append
   ) ;; entmod
  (princ)
 ) ;; defun MyImage
;; -------------------------------------------------------------------
;; Most of above source found at:
;; http://www.theswamp.org/index.php?topic=23762.new
;; -------------------------------------------------------------------
(defun c:TEST (/ My_Image My_Point My_XLato)
   (setq My_Image (getfiled "\nSelect a raster image: " "" "Jpg;Png;Tif;Gif;Bmp;Tga;Pcx" 8))
   (setq My_Point (getpoint "\nSelect an insertion point: "))
   (setq My_XLato (getreal  "\nInput length of X side: "))
   (MyImage My_Image My_Point My_XLato)
   (princ "\nDone\n")
   (princ)
) ;; defun C:TEXT
;; -------------------------------------------------------------------

 

It works on AutoCAD 2022, while on AutoCAD 2025 it crashes

Thanks for your attention

Riccardo

 

Test-Image.Lsp

Edited by Riccardo_Ferrari
Posted
On 12/10/2024 at 11:55 PM, BIGAL said:

This may be an alternative I used it to insert 100+ images.

 

(vla-AddRaster mspace name inspt 1.5 0.0) 

 

 

 

 

 

Thanks for the suggestion.
Unfortunately vla-AddRaster has a serious flaw: it names the inserted images with random names instead of the image name,
I saw online that, with other Lisp, you can change the image name, but it's an additional complication.

Regards

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...