.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Override the default parameter of the AutoCAD's command

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
ptranU2KHX
310 Views, 4 Replies

Override the default parameter of the AutoCAD's command

Hi everyone,

 

Thank you for reading my post. 

I have already searched for methods to override the default parameter of the AutoCAD's command but I have not found one yet.

e.g MTEXT command, I would like to have 'Line spacing' will be the default parameter.

ptranU2KHX_0-1667643941482.png

 

Are there any methods for this? Thank you.

4 REPLIES 4
Message 2 of 5
JamesMaeding
in reply to: ptranU2KHX

when faced with hard coded defaults, many times we will use scripting (meaning sendcommand or whatever) to draw some text to set def's, then erase, then draw what we want.

You are not being clear if you want to only use .net to do this, or if you just found this part of the forum and are asking a general question.

I would typically do this with lisp.


internal protected virtual unsafe Human() : mostlyHarmless
I'm just here for the Shelties

Message 3 of 5
ptranU2KHX
in reply to: JamesMaeding

Thanks for your reply.

 

I am using .net for working on with my projects. The request is when user hits 'space bar', AutoCAD will repeat the command with the same action when they call my command method.

 

e.g. I have a command method to call 'qleader' command with 'Line spacing' as default. However, when user hits 'space bar', it calls 'qleader' with the default parameter instead of 'Line spacing'. Therefore, I think it will be great to have some ways to override the default parameter of 'qleader' so that when it calls again, the 'Line spacing' will be set as default.

Message 4 of 5
_gile
in reply to: ptranU2KHX

Hi,

As a general rule, if you want to have more control than the native controls offer, it is better to define your own custom commands than to try to modify the behavior of the native ones.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 5 of 5
JamesMaeding
in reply to: ptranU2KHX

@ptranU2KHX 

That us a different subject, and I recall gile spoke about that in another thread recently.

The issue is you seem a bit new at programming acad and behavior of command line and so on.

This situation happens with lisp, where you can run a function  as a function, like (dosomething),

or it can be defined as a command like (defun c:dosomething ()(code.......)) and then that runs as a command.

When you hit enter, it reruns it.

So one approach is to wrap your .net command in a lisp statement, and we do this normally anyway for key ins, like:

(defun c:DS ()(command "dosomething")(princ))

 

That DS could be anything, and you can put other kinds of things where i have (command "dosomething").

Gile is much better at .net context advice, and he gave that in the other thread. Nice of him to repeat that since Kean talked about it back when Autodesk had their act together.


internal protected virtual unsafe Human() : mostlyHarmless
I'm just here for the Shelties

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

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report