Jump to content

Need Lisp code for pick the text in drawing and save in clipboard


hosyn

Recommended Posts

Dear Lee mac

I get code from MP it's:

(defun _SetClipBoardText ( text / htmlfile result )

   ;;  Caller's sole responsibility is to pass a
   ;;  text string. Anything else? Pie in face.

   ;;  Attribution: Reformatted version of
   ;;  post by XShrimp at theswamp.org.
   ;;
   ;;  See http://tinyurl.com/2ngf4r.

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

   (vlax-release-object htmlfile)

   text

)

and i dont know how i can use it . I know for Lisp file that begin with C: (defun c:aaaa()) ... and i run the name command after c:. but about the above code I dont know the name of command ?? and at this situation i usually add a new line with the define name i choose for it .

Link to comment
Share on other sites

MP's _SetClipBoardText function is not a full program which may be called at the command-line as a command; this is a function (just like built-in AutoLISP functions), requiring a single argument representing a string to copy to the clipboard.

 

As stated in my earlier post, you will need to build a program to call this function with the text content that is to be copied to the clipboard; the function I have suggested is the core engine of such a program, you will need to write the calling program.

Link to comment
Share on other sites

Dear Lee mac

I usually convert this function to self command file by:

 

[color=seagreen](defun c:LLL()[/color]

The above code

[color=seagreen])[/color]

And generally it became okey.But now don't act well.

What's wrong in my way??

Link to comment
Share on other sites

hosyn, I forget whether you are trying to learn to code or not. For now, I will assume you are. You need to pass the text value to that function, which means you need to extract it from the text object, which can generally be done using the DXF code 1 for text value. Of course the user has to be prompted to select the object first, then you go from there.

Link to comment
Share on other sites

Dear neophoible

Indeed I eagerly wanna learn the codes and I attempt so much . but sometimes I feel that i'm in the end point and i cannot go more .same that above code .

I understand your talking but i don't know how i can use them i know that this function need to argumant but i don't know how i can write the codes for it:cry:

Link to comment
Share on other sites

hosyn,

 

Pretend that you have never seen the code for the _SetClipBoardText function or that you don't have access to the source code (just as you don't have access to the source code for the getstring function).

 

Without access to the source code, the only thing you know is that the function requires a single string argument and will copy the supplied string to the Windows clipboard before returning the value of the supplied string:

([font=Courier New][color=blue]_SetClipBoardText[/color][/font] "your string here")
=> "your string here"

Consider that you don't have access to the source code for the getstring function, or any other built-in AutoLISP function for that matter, and yet you are still able to use these functions in your programs by knowing their required arguments, expected behaviour, and the value they return.

 

How would you proceed?

Link to comment
Share on other sites

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...