Jump to content

Call lisp command from the code


samifox

Recommended Posts

hi

 

i find it impossible to call a lisp command from the code, for example

 

(command "breakline" p1 p2 mid 

 

wont work

 

why is that?

 

Thanks

Shay

Link to comment
Share on other sites

hi

i find it impossible to call a lisp command from the code, for example

(command "breakline" p1 p2 mid 

wont work

why is that?

 

Hi Shay,

the "breakline" function was not written to be called from other function, however is it possible to call the "breakline" function using a script file, and this can be done in code.

As a "demo"

(defun c:demo ( / f fo p1 p2 p3 pt1 pt2 pt3)
 (if (and (setq p1 (getpoint "\nPick start point:"))
   (setq p2 (getpoint "\nPick end point:"))
     )
   (progn
     (setq p3	(polar p1 (angle p1 p2) (/ (distance p1 p2) 2))
    pt1	(strcat	(rtos (car p1) 2 16)
		","
		(rtos (cadr p1) 2 16)
		","
		(rtos (caddr p1) 2 16)
	)
    pt2	(strcat	(rtos (car p2) 2 16)
		","
		(rtos (cadr p2) 2 16)
		","
		(rtos (caddr p2) 2 16)
	)
    pt3	(strcat	(rtos (car p3) 2 16)
		","
		(rtos (cadr p3) 2 16)
		","
		(rtos (caddr p3) 2 16)
	)
    f	"c:/Windows/Temp/temp.scr"
    fo	(open "c:/Windows/Temp/temp.scr" "W")
     )
     (write-line "breakline" fo)
     (write-line pt1 fo)
     (write-line pt2 fo)
     (write-line pt3 fo)
     (close fo)
     (command "_.script" "c:/Windows/Temp/temp.scr")
   )
 )
 (princ)
)

 

Hope that helps

Henrique

Link to comment
Share on other sites

You may find you can use breakline I may be wrong but if its a Express lisp then you may need to call it in a different way the example I know is EXTRIM its called by using a different lisp defun sequence. Alternative is to write a defun that does the same thing put in your autoload lisps then its 1 line in your program. Maybe Google "Express Breakline"

 

(load "Extrim")
(etrim obj pt1)

Link to comment
Share on other sites

Found it Breakl.lsp in \program files\autodesk\Autocad 2013\express, directory you will need to go inside the main defun C:Breakline and find the defun start point like extrim above should be able to run using your pts.

 

Maybe just try (C:breakline) in your code much simpler.

Link to comment
Share on other sites

You may find you can use breakline I may be wrong but if its a Express lisp then you may need to call it in a different way the example I know is EXTRIM its called by using a different lisp defun sequence. Alternative is to write a defun that does the same thing put in your autoload lisps then its 1 line in your program. Maybe Google "Express Breakline"

 

(load "Extrim")
(etrim obj pt1)

 

The "extrim.lsp" was written to be called from other function, we have the "etrim" function that requires two arguments,

;Entity-TRIM function
;takes: na - entity name
;  a - a point, the side to trim on
;NOTE: This function does not allow for the possible miss of
;      non-continuous linetypes.
;
(defun etrim ( na a / la b d e1 ...

Found it Breakl.lsp in \program files\autodesk\Autocad 2013\express, directory you will need to go inside the main defun C:Breakline and find the defun start point like extrim above should be able to run using your pts.

 

Maybe just try (C:breakline) in your code much simpler.

 

As I had previously said, the "breakline" function was not written to be called from other function, with the

(C:breakline)

we're just calling the "breakline" command, without the possibility of automating the entire command from another routine (that I think to be the OP doubt)...

 

To call the "breakline" from another routine, according to my understanding (worth what it is worth), occurs to me three ways.

 

- using a script

- vla-sendcommand method (with hard coded points)

- write a code rewriting the "breackl.lsp" and the "c:breakline" function to require points as arguments.

 

Henrique

Link to comment
Share on other sites

yes Henrique is right , incoperating the breakl.lsp to my code is about rewriting the code or hard modifying it. so im writing this functionality by my own.

 

Thanks

Shay

Link to comment
Share on other sites

...Samifox probably quicker to just write your own breakline routine as it will match your criteria.

 

... im writing this functionality by my own.

Shay,

as your goal is to incorporate "breakline" in your routine, I agree that it will be much simpler to write your own breakline routine.

 

 

Henrique

Link to comment
Share on other sites

Thank tharwat

You're welcome .

 

( what is the meaning of ur name?)

Odd question , Search the net then you may find what you are looking for .

Link to comment
Share on other sites

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