Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LISP

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
teflon
902 Views, 6 Replies

LISP

I got this function but don´t know how to call it!

Sometimes when you load a lisp it runs by itself sometimes one should call it.

I understand if it says (defun C:xxx ( ) ) you just call it after loading by whatever stands after C: here "xxx".

But what is ax: ?

 

;;; Change all text styles on all objects to specified text style
;;; (ax:ChangeTextStyleName "ISOCPEUR")
(defun ax:ChangeTextStyleName (style / sset ename i)
  (vl-load-com)
  (setq i 0)
  (setq sset (ssget "X" '((-4 . "<OR") (0 . "MTEXT") (0 . "TEXT") (-4 . "OR>"))))
  (if sset
    (repeat (sslength sset)
      (setq ename (ssname sset i))
      (setq i (1+ i))
      (vla-put-stylename (vlax-ename->vla-object ename) style)
    )
  )
  (setq sset nil)
)

6 REPLIES 6
Message 2 of 7
Ajilal.Vijayan
in reply to: teflon


I got this function but don´t know how to call it!


This a lisp function which need one argument (style) should pass to this function to work.

Even if you chage ax:ChangeTextStyleName to C:ChangeTextStyleName , you need to provide the style argument

 


But what is ax: ?


Its just a naming convention somebody used for naming their function.
This function will work even if the name is just ChangeTextStyleName.

Only thing is you need to call the function with the name you defined with defun.

 

To work this command you need to uncomment this line and keep this line at the end of the lisp.

Because the function needs to be defined before calling.

;;; (ax:ChangeTextStyleName "ISOCPEUR")

 

 

So once you load this lisp, it will run by itself.

Message 3 of 7
teflon
in reply to: Ajilal.Vijayan

Thanks!

But I can´t make it work!

Could you be nice enough to write two versions:

One runs by itself if the text style is given in the file.

And one waits for the user to to call the lisp and the style as a argument, for example (CHANGETEXTSTYLE ISO)

 

Cheers! 

Message 4 of 7
Ajilal.Vijayan
in reply to: teflon

Sure.


One runs by itself if the text style is given in the file.


Spoiler
;;; Change all text styles on all objects to specified text style
;;; This should run by itself once you appload
(defun ax:ChangeTextStyleName (style / sset ename i)
  (vl-load-com)
  (setq i 0)
  (setq sset (ssget "X" '((-4 . "<OR") (0 . "MTEXT") (0 . "TEXT") (-4 . "OR>"))))
  (if sset
    (repeat (sslength sset)
      (setq ename (ssname sset i))
      (setq i (1+ i))
      (vla-put-stylename (vlax-ename->vla-object ename) style)
    )
  )
  (setq sset nil)
)

(ax:ChangeTextStyleName "YourTextStyleName")

And one waits for the user to to call the lisp and the style as a argument, for example (CHANGETEXTSTYLE ISO)


 

Spoiler
;;; Change all text styles on all objects to specified text style
;;; This needs to called manually after loading.
;;; Once you load this file enter this at the command line
;;; (ChangeTextStyleName "YourTextStyleName")
(defun ChangeTextStyleName (style / sset ename i)
  (vl-load-com)
  (setq i 0)
  (setq sset (ssget "X" '((-4 . "<OR") (0 . "MTEXT") (0 . "TEXT") (-4 . "OR>"))))
  (if sset
    (repeat (sslength sset)
      (setq ename (ssname sset i))
      (setq i (1+ i))
      (vla-put-stylename (vlax-ename->vla-object ename) style)
    )
  )
  (setq sset nil)
)

 

 

Message 5 of 7
_gile
in reply to: Ajilal.Vijayan

Hi,

 

To have this code working as a command, the 'style' argument may be replaced by an user input.

 

(defun c:ChangeTextStyleName (/ style sset ename i)
  (vl-load-com)
  (while
    (not
      (and
	(setq style (getstring "\nEnter the style name: "))
	(tblsearch "style" style)
      )
    )
     (princ (strcat "\nThe style '" style '" do not exist."))
  )
  (setq i 0)
  (setq sset (ssget "X" '((-4 . "<OR") (0 . "MTEXT") (0 . "TEXT") (-4 . "OR>"))))
  (if sset
    (repeat (sslength sset)
      (setq ename (ssname sset i))
      (setq i (1+ i))
      (vla-put-stylename (vlax-ename->vla-object ename) style)
    )
  )
  (setq sset nil)
)

 



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 6 of 7
teflon
in reply to: Ajilal.Vijayan

Thanks all!

 

If I understand it right using C: indicates that the program can be run as a bulit in function at Command Prompt.

That is why I thought ax: had some similar mening!

(Defun ax:ChangeTextStyleName...) is kind of confusing because the routine can be run with just (Defun ChangeTextStyleName...).

Or am I wrong???

 

Message 7 of 7
Shneuph
in reply to: teflon

(Defun changetextstylename ()...  will have to be called like a lisp function

command: (changetextstylename)

 

(defun C:changetextstylename can be run as as command

command: changetextstylename

 

As Ajilal Vijayan explained earlier.. the ax: is just a naming convention that someone used for their lisp.  I use TLF- for functgions TLC- for commands TLV- for variables.. that way in the (lsp) commands it is easy to find which functions, commands, and variables I have saved by using TLF* tlv* etc to display them.  Also, in the command line all my commands are grouped together since they all start with tlc-

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost