Why does (defun c:CTTEST ().... run when TEST is run on cmd line?

Why does (defun c:CTTEST ().... run when TEST is run on cmd line?

JamesMaeding
Advisor Advisor
1,153 Views
8 Replies
Message 1 of 9

Why does (defun c:CTTEST ().... run when TEST is run on cmd line?

JamesMaeding
Advisor
Advisor

I noticed my function "CTTRAV" was being run when a user typed "TRAV".

This is in acad 2019, but happens in civil3d 2019 and I don't think its version dependent.

Is there some format of defining c: functions where you can prefix with "CT"?

try this to see:

(DEFUN C:CTTEST1 ( / )
  (princ "\nWow")
)

type TEST1 and it prints Wow.

Wow.


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

0 Likes
Accepted solutions (1)
1,154 Views
8 Replies
Replies (8)
Message 2 of 9

Kent1Cooper
Consultant
Consultant

I don't think there's anything special about the CT -- it's just the fact of TEST1 being a part  of that name, and AutoComplete taking over, so that if you hit Enter, it doesn't use just what you typed in, but what among the options offered it has highlighted.  Try typing TEST [without the 1], for which I am offered CTTEST1, and WRITESTAT, and, because I have a Hatch pattern called TEST for experiments, to Hatch using that pattern.  That latter is the one it had highlighted in the offerings, so that's what I got with TEST {Enter}, even though CTTEST1 was the top of the offerings list [I assume it's alphabetical with command names first and other things like Hatch pattern names after].  I would bet that if you also define a command called just TEST1, you won't get CTTEST1 when you type in TEST1, because the latter should be the primary offering.

 

Try turning off auto-completing of command names, an option under the -INPUTSEARCHOPTIONS command [which you will get if you type in AutoComplete directly].

Kent Cooper, AIA
0 Likes
Message 3 of 9

cadffm
Consultant
Consultant

But last command is CTTEST?

 

Autocorrection ON?

That will display also before you hit enter.

 

https://help.autodesk.com/view/ACD/2020/ENU/?guid=GUID-3B84DB63-C960-45CF-A8E1-3BB405CF3A46

 

?

Sebastian

0 Likes
Message 4 of 9

Moshe-A
Mentor
Mentor

@JamesMaeding hi,`

 

explore INPUTSEARCHOPTIONS to understand why all of this happens.

 

moshe

 

 

 

0 Likes
Message 5 of 9

JamesMaeding
Advisor
Advisor

Trust me folks, the autocomplete is not on.

I only turn that on when trying to find a command.

My current settings are:

off.jpg

 

Another interesting thing I found is it only happens for the first defun.

Try this:

(defun c:cttest ()(princ "\nWow"))

run Test, it says wow.

then run:

(defun c:ct-test ()(princ "\nWow"))

type Test, it says unknown function - like it should.

then run:

(defun c:cttest ()(princ "\nWow"))

and run Test, it says unknown function - like it should.

 

Ok, after I just wrote that, I tried on an OOTB acad profile and am not seeing this bug.

I don't expect you guys too so hold off while I narrow down more.

I did have some things loaded in my test profile like quilpik I should remove.

 

 

 


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

Message 6 of 9

JamesMaeding
Advisor
Advisor
Accepted solution

Ok, after lots of ripping apart company and default acad profiles, I think I got it down to what I consider a bug.

Indeed, the replies to check auto-correct/complete were also my first thought, and I faithfully posted the pic of them off.

But it seems they are not fully off. Note that the "Mid string search" option is greyed but on:

off.jpg

I thought those did not matter as autocomplete and autocorrect are clearly off.

But if I open the options, turn on autocomplete so I can access the mid-string search box, and turn it off as well as autocomplete, the TRAV command does nothing.

I can repeat that easily, and I expect everyone on 2019.1.2 can, and likely all acad versions since maybe 2017.

I don't think adesk considers that a bug, but I would most DEFINITELY call it a bug.

 

The odd thing is, it only seems to happen on functions the first time they are defined.

I have a .lsp names LinesCurves.lsp, with one function (DEFUN C:CT-TRAVERSE ( / )....

The first time I load that lisp, TRAV runs the function (with the mid string search on).

If I rename the function to (DEFUN C:CT-TRAVERSE1 ( / )....

and reload the lisp, TRAV does nothing now, says unknown command.

If I rename it back to (DEFUN C:CT-TRAVERSE ( / ).... and load, the TRAV does nothing now too.

So the mid string search bug only happens for functions defined in a lisp, the first time that lisp is loaded.

If the function names are the same, reloading it has no effect, the bug happens.

If you rename a function and reload a lisp, it seems to clear the search of functions from that file.

This implies the search knows where stuff came from.

 

The moral of the story is turn off mid-string search if you don't want it, as simply turning off autocomplete is not enough. thanks for watching, all.

 

 

 


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

0 Likes
Message 7 of 9

JamesMaeding
Advisor
Advisor

btw, the help is wrong:

Nope.jpg

I don't doubt its unintentional, but what a process to get to the bottom of it.


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

0 Likes
Message 8 of 9

cadffm
Consultant
Consultant

"available" is the wrong, "reachable" is the right wording : -)

It's near to the Plotmark plot.log file.. from plot dialog it is reachable when plotstamp is set to on,

independing if on or off, the plot.log is always working (depends of if the .log is set on or off).

(ok, the -log setting is available all the time via command DDPLOTSTAMP/Plotstamp), but who walk this way..)

 

Another thing:

I couldn't replicate your examples first and then i found why: This happens not when a command is defined

direct in commandline or by (lload "myfile"), but if you load a lisp by appload, with appload it is working as you wrote.

 

August-Egg 😂

 

Sebastian

0 Likes
Message 9 of 9

JamesMaeding
Advisor
Advisor

@cadffm 

it also happens if loaded by hand, by dragging in from explorer.

BTW, some do not know you can do that. I consider it way easier than the appload dialog.

It also happens if code is loaded from the VLIDE, or from a vlx compiled with the vlide.

Several odd quirks on this one.

I added this to our acaddoc.lsp:

(COMMAND-S "-INPUTSEARCHOPTIONS" "M" "NO" "")

done


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

0 Likes