Author Topic: Image fixing  (Read 317 times)

0 Members and 1 Guest are viewing this topic.

mohan

  • Newt
  • Posts: 82
Image fixing
« on: May 25, 2022, 06:07:55 AM »
Please help to fix the route.
Code - Auto/Visual Lisp: [Select]
  1. (defun c:fiximageproperties ( / Im en i ss)
  2. (if (and (ssget "_X" '((0 . "IMAGE")))
  3.          (= "Company Logo" (setq Im (cdr (assoc 3 (dictsearch (namedobjdict) "ACAD_IMAGE_DICT"))))))
  4.       (repeat (setq i (sslength Im))
  5.       (setq en (ssname ss (setq i (1- i))))
  6. (setpropertyvalue en "SCALE" 50.0)
  7. (setpropertyvalue en "Position/X" 250.0))))

"Company Logo" is the Raster image file name
« Last Edit: May 25, 2022, 06:35:51 AM by mohan »
"Save Energy"

ribarm

  • Gator
  • Posts: 2794
  • Marko Ribar, architect
Re: Image fixing
« Reply #1 on: May 25, 2022, 08:23:47 AM »
You have problems with parenthesis (brackets) at the end of routine... (if I am not blind or something else...)
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

mohan

  • Newt
  • Posts: 82
Re: Image fixing
« Reply #2 on: May 25, 2022, 08:48:04 AM »
Bracket all looks fine.
Code - Auto/Visual Lisp: [Select]
  1. (defun c:fiximageproperties ( / Im en i ss)
  2. (if (and (ssget "_X" '((0 . "IMAGE")))
  3.          (= "Companny Logo" (setq Im (cdr (assoc 3 (dictsearch (namedobjdict) "ACAD_IMAGE_DICT")))))
  4.     );and
  5.       (repeat (setq i (sslength Im))
  6.       (setq en (ssname ss (setq i (1- i))))
  7. (setpropertyvalue en "SCALE" 50.0)
  8. (setpropertyvalue en "Position/X" 250.0)));Progn
  9. );if
  10. (princ));defun

The error was !
Command: FIXIMAGEPROPERTIES
; error: bad argument type: lselsetp "Companny Logo"
"Save Energy"

kirby

  • Newt
  • Posts: 111
Re: Image fixing
« Reply #3 on: May 25, 2022, 10:59:49 AM »
Errors/Issues were:
- ss not declared (renamed to MySet)

Suggestions
- clean up if and repeat loop structure indenting so code is readable
- should do uppercase string comparison
- good idea to move specific 'Company Logo' string outside of the code (or make a global variable if you are using it in different functions), and make it an input

- note there is a possible typo in image name 'CompanNy Logo' (extra 'n')




Code - Auto/Visual Lisp: [Select]
  1. (defun c:fiximageproperties ( / Im en i MySet)
  2. ; Fix image properties for company logo
  3.  
  4. (setq #MyLogoName (strcase "Company Logo"))
  5.  
  6. (if (and (setq MySet (ssget "_X" '((0 . "IMAGE"))))
  7.          (eq #MyLogoName (setq Im (strcase (cdr (assoc 3 (dictsearch (namedobjdict) "ACAD_IMAGE_DICT"))))))
  8.     ) ;and
  9.   (progn
  10.         (repeat (setq i (sslength MySet))
  11.                 (setq en (ssname MySet (setq i (1- i))))        ; backwards increment
  12.                 (setpropertyvalue en "SCALE" 50.0)
  13.                 (setpropertyvalue en "Position/X" 250.0)
  14.         )
  15.   ) ;progn
  16. ) ;if
  17.  
  18. ) ;defun
  19.  

mohan

  • Newt
  • Posts: 82
Re: Image fixing
« Reply #4 on: May 25, 2022, 12:00:57 PM »
Errors/Issues were:
- ss not declared (renamed to MySet)

Suggestions
- clean up if and repeat loop structure indenting so code is readable
- should do uppercase string comparison
- good idea to move specific 'Company Logo' string outside of the code (or make a global variable if you are using it in different functions), and make it an inpu
- note there is a possible typo in image name 'CompanNy Logo' (extra 'n')


Thanks a lot . . .
 :smitten:
"Save Energy"