Jump to content

Recommended Posts

Posted

Hi everybody !

I found it on the forum. But when I use it, I get this error: bad argument type  "iselsetp nil

Please review and help me fix this error. thank you very much

defun C:CHANGESTYLE (/ entities len count ent ent_data ent_name new_style_name)

(command "STYLE" "iso" "isocp.shx" "" "" "" "" "")
(setq entities (ssget "X" '((0 . "TEXT")))
     len      (sslength entities)
     count 0
);setq

(while (< count len)
      (setq ent      (ssname entities count)
            ent_data (entget ent)
            ent_name (cdr (assoc 7 ent_data))
      );setq

(setq new_style_name (cons 7 "iso"))
(setq ent_data (subst new_style_name (assoc 7 ent_data) ent_data))
(entmod ent_data)

(setq count (+ count 1))
);while

;;;runs same routine again, picking up Mtext this time.

(setq entities (ssget "X" '((0 . "MTEXT")))
     len      (sslength entities)
     count 0
);setq

(while (< count len)
      (setq ent      (ssname entities count)
            ent_data (entget ent)
            ent_name (cdr (assoc 7 ent_data))
      );setq

(setq new_style_name (cons 7 "iso"))
(setq ent_data (subst new_style_name (assoc 7 ent_data) ent_data))
(entmod ent_data)

(setq count (+ count 1))
);while

(princ)

);defun

Posted (edited)

Hi
I think there is either no TEXT or no MTEXT in your drawing
That's why the code below can't work.

I've edited your code with my smartphone to try to fix this.
So I can't test it, but it should work

 

(defun C:CHANGESTYLE (/ entities len count ent ent_data ent_name new_style_name)

(command "STYLE" "iso" "isocp.shx" "" "" "" "" "")
(if (setq entities (ssget "X" '((0 . "TEXT")))) 
  (progn
     (setq len      (sslength entities)
     count 0
);setq

(while (< count len)
      (setq ent      (ssname entities count)
            ent_data (entget ent)
            ent_name (cdr (assoc 7 ent_data))
      );setq

(setq new_style_name (cons 7 "iso"))
(setq ent_data (subst new_style_name (assoc 7 ent_data) ent_data))
(entmod ent_data)

(setq count (+ count 1))
);while
) ;progn
);if

;;;runs same routine again, picking up Mtext this time.

(if (setq entities (ssget "X" '((0 . "MTEXT")))) 
  (progn
     (setq len      (sslength entities)
     count 0
);setq

(while (< count len)
      (setq ent      (ssname entities count)
            ent_data (entget ent)
            ent_name (cdr (assoc 7 ent_data))
      );setq

(setq new_style_name (cons 7 "iso"))
(setq ent_data (subst new_style_name (assoc 7 ent_data) ent_data))
(entmod ent_data)

(setq count (+ count 1))
);while
);progn
);if

(princ)

);defun

 

Edited by GLAVCVS
Posted

So the error lselsetp is saying it is looking for a selection set (ssget) and didn't find one, often when you have asked it to say, select text but no text was selected - the selection set wasn't created.

 

As above, it is good practice to check that a selection set has been found before you do anything with it

Posted

Here you go.

(defun c:Test (/ int sel ent get)
  ;;--------------------------------------------;;
  ;; Author : Tharwat Al Choufi			;;
  ;;						;;
  ;; www.AutolispPrograms.WordPress.com		;;
  ;;--------------------------------------------;;
  (and (or (tblsearch "STYLE" "iso")
           (entmake '((0 . "STYLE")
                      (100 . "AcDbSymbolTableRecord")
                      (100 . "AcDbTextStyleTableRecord")
                      (2 . "iso")
                      (70 . 0)
                      (40 . 0.0)
                      (41 . 1.0)
                      (50 . 0.0)
                      (71 . 0)
                      (42 . 100.)
                      (3 . "isocp.shx")
                      (4 . "")
                     )
           )
       )
       (or (setq int -1 sel (ssget "_X" '((0 . "TEXT,MTEXT"))))
           (alert "No texts found in this drawing.!")
       )
       (while (setq int (1+ int) ent (ssname sel int))
         (and (setq get (entget ent))
              (entmod (subst '(7 . "iso") (assoc 7 get) get))
         )
       )
  )
  (princ)
)

 

  • Like 1
Posted

Thank you @Tharwat! I Just want to change the selected font! Please help me !

Posted
5 hours ago, CAD2005 said:

Thank you @Tharwat! I Just want to change the selected font! Please help me !

Now you are asking for another go.

Posted (edited)

yes! please help@tharwat

Edited by CAD2005
Posted

Change this line: 

 

(3 . "isocp.shx")

 

To your preferred text. Should create the dimension style to suit.

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...