Are you saying that CHAMFER doesn't trim the corners, and you are trying to make a routine that does?
If that's the issue, you probably just have the TRIMMODE System Variable set to 0, when it should be set to 1. Then ordinary CHAMFER will trim the corners.
If that's not the issue, explain in more detail. The code is hard to test, because it needs a lot of fixing [is it an AI effort? ChatGPT, for example, is notoriously bad at AutoLisp, so far]. But I notice a couple of things to start with:
The Chamfer distances should not be in a list. Do this instead:
(command "_.chamfer" "_distance" dc dc)
which in an AutoLisp (command) function concludes the command, so you need to start it again:
(command
"_.chamfer" "_distance" dc dc
"_.chamfer" s1 s2
)
But s1 and s2 there require just entity names, not VLA objects, and the same is true for some later usages. So you may need to store them in both forms under different variable names.
The TRIM commands near the end should be using 'line' as the first selection [cutting boundary] and 's1'/'s2' as the second, but that's going to need to be a location, not just the object, so it knows which part to Trim off. And they could be in one TRIM command, and they need to conclude it -- all signs of ChatGPT's ignorance of the details.
But all that may be irrelevant, if the only issue is the TRIMMODE setting.
Kent Cooper, AIA