5/16/2023 0 Comments Autocad copyclipIn the next few days I'll be heading up to the mountains for Autodesk's annual "week of rest" closure, but I'll almost certainly have the odd tidbit to share while I'm there. That’s really left as an exercise for the reader, depending on the specific needs. You may find these commands more verbose on the command-line, as we’re selecting once before passing through to COPYCLIP, for instance, but we could streamline then somewhat to not echo the command-strings, at least. Now when we use Ctrl-C and -V to copy or paste in AutoCAD, we have our custom behaviour kick in. If the normal PASTECLIP command is to be called, we anyway prefix the command-string with escape characters to cancel any active commands. We’ve removed the "”^C^C” prefix from the Ctrl-V call – replacing it with an apostrophe – because we want our new command to be transparently callable, something that is really only useful if we’re sending text data from the clipboard to the command-line. To really make this work properly from Ctrl-C and -V, we need to use the CUI command to reassign the macro for Copy and Paste to “^C^C_ccint” and “’_pcint”, respectively: "\n entities selected.\n", ĭoc.SendStringToExecute( "_.COPYCLIP ", true, false, true ) Report how many objects have been selected we need to set it from the selection for COPYCLIPĮd.SetImpliedSelection(()) In case the selection is not from the pickfirst set, Start by getting the pickfirst set or object selection a transparent command, but one with pickfirst support For the command that intercepts COPYCLIP, we need not only If there is some, send it to the command-lineĭoc.SendStringToExecute(text, true, false, true ) Var text = ( string )obj.GetData( "Text" ) If not, try to get text data from the clipboard "\x1B\x1B_.PASTECLIP ", true, false, true active commands (we may have been called transparently) If so, start the PASTECIP command, cancelling any Find out whether the clipboard contains AutoCAD data about the pickfirst set: it just needs to be transparentĪpplication. For our command to intercept PASTECLIP, we don't care We might also use this opportunity to add certain objects into the operation (although there are other ways this might be achieved inside AutoCAD). At a basic level, we can just hook into Ctrl-C and then look at the selection set chosen by the user: in our case we’re just going to write a message to the command-line mentioning the number of objects selected, but we might choose only to call COPYCLIP under certain circumstances. I decided to generalise the request (and ultimately the solution) to encompass copy operations, too. If it contains text, send it to the command-line. For instance, if the clipboard contains drawing data, let the PASTECLIP command have at it. This really sounded like an interesting little problem but also a very useful bit of functionality: basically you could have AutoCAD change its “paste” behaviour based on the type of data in the clipboard. Maybe this is just running a little function that runs before paste. I would want the “enhanced paste” routine to be able to run inside any other command gracefully. Its the transparent part I have never done. So I think I need to write a transparent function, make a command in the CUI that runs the function, and assign ctrl-v to it. I already tried removing the keyboard shortcuts to ctrl-v via the cui, and that just makes ctrl-v not do anything when command line does not have focus. I do not use ctrl-v for pasting entities, only text to command line. I thought this might be a topic you would be interested in. I genuinely didn’t think I’d manage to look into it before the break, but it tweaked my interest during my trip back from the UK: This was a fun question that came in from James Meading.
0 Comments
Leave a Reply. |