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

dSettings cannot work tranpeearently when calling inside lisp code

22 REPLIES 22
SOLVED
Reply
Message 1 of 23
GeryKnee
720 Views, 22 Replies

dSettings cannot work tranpeearently when calling inside lisp code

the following lisp command


(defun C:TT ()
   (command "._+dsettings" "2")
   (setq ChMode (logand OutMode 16383))
   (setvar "osmode" ChMode)
   (princ)
)

 

works when when calling from autocad

when you try to call it tranparently (example Polyline pnt1 pnt2 .. 'TT ..) does not work

Please answer me if there is a solution to work

Thanks

Regards,

Gery

22 REPLIES 22
Message 2 of 23
hmsilva
in reply to: GeryKnee


GeryKnee wrote:

when you try to call it tranparently (example Polyline pnt1 pnt2 .. 'TT ..) does not work


Hello Gery and welcome to the Autodesk Community!

 

Assuming the OutMode variable was set before, perhaps defining the command call, transparent will do the trick...

(command "'._+dsettings" "2")

 

Hope that helps
Henrique

EESignature

Message 3 of 23
GeryKnee
in reply to: hmsilva

Thanks HmSilva

unfortunatelly it does not work

the problem is :

when typing in autocad polyline pnt1 pnt2 ... 'dsettings 2 pnt3 pnt4 ... , works ok

i write the code
(defun C:TT ()
   (command "'dsettings" "2")
   (princ)
)

Now typing in autocad polyline pnt1 pnt2 ... ;TT pnt3 pnt4 ... , i wait to work opening the dsettings dialog as trasparent call.

But that doesn't happen , answering
Point or option keyword required.
; error: Function cancelled

The same happens using any alternate syntax of command call like
   (command "'dsettings" "2")
   (command "'+dsettings" "2")
   (command "._+dsettings" "2")
   (command "'._+dsettings" "2")
   (command "._dsettings" "2")

etc

That means that the lisp server cancels the running polyline user insert chain

How can this work withowt breaking this chain?

 

Message 4 of 23
hmsilva
in reply to: GeryKnee


GeryKnee wrote:

unfortunatelly it does not work


Gery,

 

using

(defun C:TT ()
  (command "'._+dsettings" "2")
  (princ)
)

it works ok for me...

From the command line:

Command: pline

Specify start point:
Current line-width is 0.0000
Specify next point or [Arc/Halfwidth/Length/Undo/Width]:
Specify next point or [Arc/Close/Halfwidth/Length/Undo/Width]: 'tt
'._+dsettings >>Tab Index <0>:2
Resuming PLINE command.
Specify next point or [Arc/Close/Halfwidth/Length/Undo/Width]:
Specify next point or [Arc/Close/Halfwidth/Length/Undo/Width]: 'tt
'._+dsettings >>Tab Index <0>:2
Resuming PLINE command.
Specify next point or [Arc/Close/Halfwidth/Length/Undo/Width]:

Command:

 

Try to change the command name, maybe you're calling another TT.lsp ???

EDIT: Tested on AC2010

 

Henrique

EESignature

Message 5 of 23
GeryKnee
in reply to: hmsilva

 

I use Autocad 2006

 


(defun C:TT ()
  (command "'._+dsettings" "2")
  (princ)
)

 

using another name


Command: _pline
Specify start point:
Current line-width is 0.0000
Specify next point or [Arc/Halfwidth/Length/Undo/Width]:
Specify next point or [Arc/Close/Halfwidth/Length/Undo/Width]: 'tt
'._+dsettings
2D point or option keyword required.
; error: Function cancelled
Specify next point or [Arc/Close/Halfwidth/Length/Undo/Width]:
Command: *Cancel*

 


(defun C:ABCDE ()
  (command "'._+dsettings" "2")
  (princ)
)

 


Command: _line Specify first point:
Specify next point or [Undo]:
Specify next point or [Undo]: 'ABCDE
'._+dsettings
Point or option keyword required.
; error: Function cancelled
Specify next point or [Undo]: *Cancel*

 

 

Message 6 of 23
hmsilva
in reply to: GeryKnee

Untested, try

 

(defun c:test ()
  (command "'osnap")
  (princ)
)

 

HTH

henrique

EESignature

Message 7 of 23
GeryKnee
in reply to: hmsilva

 

 

the same


Command: _pline
Specify start point:
Current line-width is 0.0000
Specify next point or [Arc/Halfwidth/Length/Undo/Width]:
Specify next point or [Arc/Close/Halfwidth/Length/Undo/Width]: 'test
'osnap
2D point or option keyword required.
; error: Function cancelled

 

Message 8 of 23
hmsilva
in reply to: GeryKnee

Gery,

I'm sorry, but I can't understand why is not working as expected, and with AC2010 I can't reproduce this behavior.
Hopefully someone else will step in with a better solution.


Henrique

EESignature

Message 9 of 23
GeryKnee
in reply to: hmsilva

 

Thanks Henrique for your help.

Maybe version of 2006 has a problem , but i use this version and i prefere it.

Anyway, thanks again.

Regards,

Gery

Message 10 of 23
paullimapa
in reply to: GeryKnee

What if you define the function without the C: like this: (defun TT

Then at the prompt call the function within parentesis like this: (TT)


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 11 of 23
GeryKnee
in reply to: paullimapa

 

 

Hi Paul

 

I wrote this at my lsp file

 


(defun TT ()
   (command "'._+dsettings" 2)
   (princ)
)

 

after that typing
Command:
Command: _pline
Specify start point:
Current line-width is 0.0000
Specify next point or [Arc/Halfwidth/Length/Undo/Width]:
Specify next point or [Arc/Close/Halfwidth/Length/Undo/Width]: '(TT)
2D point or option keyword required.
Specify next point or [Arc/Close/Halfwidth/Length/Undo/Width]: *Cancel*

 

do you have differnt response in your autocad version?

 

Regards,

Gery

 

 

Message 12 of 23
paullimapa
in reply to: GeryKnee

Would it work if you do not preceed the command with an apostrophe?

So instead of '(TT), just use (TT)


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 13 of 23
GeryKnee
in reply to: paullimapa

 

Hi Paul

 

if i'm not wrong you mean


(defun TT ()
   (command "'._+dsettings" 2)
   (princ)
)

 

testing :::


Command: _line Specify first point:
Specify next point or [Undo]:
Specify next point or [Undo]: '(TT)
Point or option keyword required.
Specify next point or [Undo]: *Cancel*

 

 

I thing it's expected because functions are calling from commands but commands (C:) are the only that could be called from autocad

 

Regards,

Gery

 

Message 14 of 23
paullimapa
in reply to: GeryKnee

Once you've defined a function assumming +dsettings can really be executed transparently in AutoCAD 2006, then you should be able to call the function within a standard AutoCAD command:

 

Command: _line Specify first point:
Specify next point or [Undo]:
Specify next point or [Undo]: (TT)

 

This is where you would enter (TT) without the need to place the apostrophe
.

See if this works in AutoCAD 2006.


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 15 of 23
paullimapa
in reply to: GeryKnee

You should also try changing your (TT) function as Henrique suggested to use 'OSNAP which AutoCAD 2006 should see as transparent:

(defun TT ()
  (command "'osnap")
  (princ)
)

 

Then call (TT) from within AutoCAD's LINE command but again without preceeding with an apostrophe:

 

Command: _line Specify first point:
Specify next point or [Undo]:
Specify next point or [Undo]: (TT)


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 16 of 23
GeryKnee
in reply to: paullimapa

 

 

The code


(defun TT ()
   (command "'._+dsettings" 2)
   (princ)
)

 

Autocad

 


Command: _line Specify first point:
Specify next point or [Undo]:
Specify next point or [Undo]: (TT)
'._+dsettings
Point or option keyword required.
; error: Function cancelled
Specify next point or [Undo]: *Cancel*

 

Is that what you say ?

 

 

 

Message 17 of 23
paullimapa
in reply to: GeryKnee

So it looks like AutoCAD 2006 does not support +dsettings as a transparent command yet.

As I metioned, try the 'OSNAP command which I believe AutoCAD 2006 does support transparently.

 

(defun TT ()
  (command "'osnap")
  (princ)
)


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 18 of 23
GeryKnee
in reply to: paullimapa

 


Command:
Command: _line Specify first point:
Specify next point or [Undo]:
Specify next point or [Undo]: (TT)
'osnap
Point or option keyword required.
; error: Function cancelled
Specify next point or [Undo]: *Cancel*

Message 19 of 23
paullimapa
in reply to: GeryKnee

I just loaded Acad 2006 and it's definitely a limitation with that version.

 

A workaround is this.
Write a function called keystuff that'll send the command to the keyboard buffer using vla command:

(defun keystuff (cmd-arg)(vla-Sendcommand(vla-Get-ActiveDocument(vlax-Get-Acad-Object))cmd-arg))

 

Then define the TT function anway you like invoking keystuff:

(defun C:TT () (keystuff"'OSNAP\n"))

 

Now when you start the Line command and enter 'TT it'll transparently bring up the OSNAP option window and allow you to continue your Line pick point option.


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 20 of 23
GeryKnee
in reply to: paullimapa

 

 

 

 

Semi - Solved

 

i wrote


(defun keystuff (cmd-arg)(vla-Sendcommand(vla-Get-ActiveDocument(vlax-Get-Acad-Object))cmd-arg))
(defun C:TT ()
   (keystuff"'OSNAP\n")
   (setq ChMode (logand OutMode 16383))
   (setvar "osmode" ChMode)
)

 

calling from autocad the osnap dialog opens but ...

 

creating a button to call the command

the button call will be 'TT

 

1) ::: using not tranparently

 


Command: *Cancel*
Command: 'TT
; error: bad argument type: fixnump: nil
Command:
Command: 'OSNAP
Command:

 

 

2 ::: using tranparently


Command: _line Specify first point:
Specify next point or [Undo]:
Specify next point or [Undo]: 'TT
; error: bad argument type: fixnump: nil
Specify next point or [Undo]:
Specify next point or [Undo]: 'OSNAP
Resuming LINE command.
Specify next point or [Undo]: >>
Resuming LINE command.
Specify next point or [Undo]: *Cancel*

 

 

My problem is that autodesc changed the way osnap changes using dsettings or osnap dialog from what was defined in autocad 14.

When user sets snap using the dialog window  (ex. adds snap to circle) waits after closing the dialog to set the osnap flag ON without having to press the osnap button.

My opinion is that this progress to autocad application is bad and i try to recover it.

Not knowing if i changed OK or CANCEL to dialog , i prefere to ALWAYS CHANGE THE FLAG ON after closing the dialog.

 

 

 

 

 

 

 

 

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

Post to forums  

Autodesk Design & Make Report

”Boost