Jump to content

Automatically paste string to autocad command


Recommended Posts

Posted

Is there a way to paste a string of text from a program like Excel into the command line while a command is active while within a running lisp.

 

Example, I would like to create a line of text, "BBD-1230-G" as a TEXT, and do so only typing in one command.

 

Something like this:

 


(defun c:pastetext ()
 (command "_.-text" '(0 0 0) 1 0 pastefunction)
 (princ))

Posted

seriously? man, i wanna just delete this post and pretend it never happend.

Posted

its not working, probably something simple...

 

(command "_.-PN" ctrl-v "0,0" "0" (command ""))

 

What am i doing wrong?

Posted

The company I work for uses a third party software called Project Matrix to manage/distribute thier 2-D and 3-D symbols. The command to insert a symbol is "PN" to use the dialog box or "-PN" to use the command line. It works alot like insert. First it asks for the part number (what I want to paste from an excel spreadsheet), then insertion point (90% of the time is (0,0,0), finally rotation angle (also 90% of the time its 0), then it askes for a second insertion point, which I don't want to do, so I cancel the command with "(command "") ***but now that i think of it a "" will do just fine.

 

(command "_.-PN" ctrl-v "0,0" "0" "")

Posted

Ctrl-V is a keystroke, and will be treated just as any other symbol.

 

Your example used text, so I suggested Ctrl-V to insert the text into AutoCAD.

Posted

Perhaps take a look at this function by the great MP:

 

;;  MP
(defun _GetClipBoardText( / htmlfile result )

   (setq result
       (vlax-invoke
           (vlax-get
               (vlax-get (setq htmlfile (vlax-create-object "htmlfile")) 'ParentWindow)
              'ClipBoardData
           )
          'GetData "Text")
   )
   (vlax-release-object htmlfile)
   result
)

Posted
Ctrl-V is a keystroke, and will be treated just as any other symbol.

 

Your example used text, so I suggested Ctrl-V to insert the text into AutoCAD.

 

I was just about to reply and ask if this is what the confusion was...

 

Perhaps take a look at this function by the great MP:

 

Code:

;; MP(defun _GetClipBoardText( / htmlfile result ) (setq result (vlax-invoke (vlax-get (vlax-get (setq htmlfile (vlax-create-object "htmlfile")) 'ParentWindow) 'ClipBoardData ) 'GetData "Text") ) (vlax-release-object htmlfile) result)

 

This works perfectly. Thanks again man.

Posted

Not that MP's function doesn't fit the bill, and it does quite well, but I wanted to mention that dos_lib has a Copy and Paste to Clipboard function.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...