Jump to content

Recommended Posts

Posted
(vl-load-com)
(defun c:vv (/ en tx html)		
  (and (setq en (ssget '((0 . "*TEXT"))))
       (setq en (ssname en 0))
       (setq en (vlax-ename->vla-object en))
       (vlax-property-available-p en 'textstring)
       (setq tx (vla-get-textstring en))
       (vlax-invoke
	 (vlax-get (vlax-get (setq html (vlax-create-object "htmlfile"))
			     'ParentWindow
		   )
		   'ClipBoardData
	 )
	 'setData
	 "text"
	 tx
       )
       (vlax-release-object html)
  )
  (princ)
)

 

Hello, everyone。I am looking for a way to copy the picture to the clipboard, what is the way? This is what I found on the forum and it only implements text to clipboard. Is there a way to find out which properties or objects are supported behind the 'setdata method? E.g "picture"

Posted (edited)

These work if you're using Windows

 

Press Windows logo key + Shift + S. The desktop will darken while you select an area for your screenshot.

Press PrtScn to copy the entire screen to the clipboard or press Alt + PrtScn to copy the active window to the clipboard.

Clipboard in Windows

 

Not sure what you're trying to do but for creating PNG images for AutoCAD macros I usually use PNGOUT.

Edited by tombu
  • Agree 1
Posted
59 minutes ago, tombu said:

These work if you're using Windows

 

Press Windows logo key + Shift + S. The desktop will darken while you select an area for your screenshot.

Press PrtScn to copy the entire screen to the clipboard or press Alt + PrtScn to copy the active window to the clipboard.

Clipboard in Windows

 

Not sure what you're trying to do but for creating PNG images for AutoCAD macros I usually use PNGOUT.

For example, the picture of the path "C:\Users\Administrator\Desktop\test.jpg", how to use lisp to put it on the clipboard.

Posted

So what will you do with the image once you have it there?

 

In AutoCAD there are often many ways to do stuff, so what you might do - copy to clipboard and then paste, there might be another way to do the same thing such as insert? Then something like this might work using the source file directly 

 

 

I think you can also use copyclip - manually selecting the image:

 

(command "copyclip" pause pause)

 

 

or ssget filtering by (0 "IMAGE")

 

 

(command "copyclip" (ssget "_X" '((0 . "IMAGE"))) pause)


-or-

(command "copyclip" (ssget "_X" '((0 . "IMAGE"))) "")

 

Posted (edited)
29 minutes ago, Steven P said:

 

I think you can also use copyclip - manually selecting the image:

 

(command "copyclip" pause pause)

 

 

or ssget filtering by (0 "IMAGE")

 

 

(command "copyclip" (ssget "_X" '((0 . "IMAGE"))) pause)


-or-

(command "copyclip" (ssget "_X" '((0 . "IMAGE"))) "")

 

This copy can only be done in CAD, what I hope is that it can be copied at will in windows, for example, it can be copied to Microsoft word

Edited by ekko
Posted

Ahh, just checking, yes, it appears to paste in Word as an OLE, double click and it opens the image back in CAD

  • Thanks 1
Posted

I know that TEXT is the only way to use HTML files.

 

If that were possible, the problem in this link would not have been turned around like this.

 

In MS WORD, there is a button to capture the screen in the SCREENSHOT menu. 

move that button to outside of ribbon menu 

and then putting MS WORD next to the CAD window

it will be easier to use it. i think

 

  • Thanks 1
Posted
2 hours ago, exceed said:

I know that TEXT is the only way to use HTML files.

 

If that were possible, the problem in this link would not have been turned around like this.

 

In MS WORD, there is a button to capture the screen in the SCREENSHOT menu. 

move that button to outside of ribbon menu 

and then putting MS WORD next to the CAD window

it will be easier to use it. i think

 

This is the problem of the previous post. When the picture is placed in the excel table and then saved, and the table is opened again, the picture will not be displayed, because the table is only a simple link, and lsp has deleted the screenshot, except for saving the picture to a file. folder, is there any other way to ensure the normal display of the picture, thank you, my brother

Posted

Maybe this is not the best place for question/answer... If you search for OS/DOS/Windows task, perhaps *.bat (batch scripting) is the most appropriate way to accomplish desired result... Try searching Stack Overflow or similar www sites... I am sure it was asked before and many times... Good luck...

Posted (edited)
1 hour ago, ekko said:

This is the problem of the previous post. When the picture is placed in the excel table and then saved, and the table is opened again, the picture will not be displayed, because the table is only a simple link, and lsp has deleted the screenshot, except for saving the picture to a file. folder, is there any other way to ensure the normal display of the picture, thank you, my brother

 

That's my mistake. In order to prevent a lot of unnecessary image files from being created,

I used the method of replacing the image file names with one. 

 

Since the timing of saving the image in Excel is the timing of saving the workbook, the files referenced by the same name before that time become as if the file does not exist. 

 

Therefore, at the beginning of all the code If you fix this line 

            ph  (strcat (getvar "dwgprefix") (vl-filename-base (getvar "dwgname")) ".wmf") ;edited line

like this, 

            ph  (strcat (getvar "dwgprefix") (vl-filename-base (getvar "dwgname")) "-" (rtos (getvar 'cdate) 2 10) ".wmf") ;edited line

there should be no problem. Unless you shoot twice in 0.0001 second.

 

i edited original post

Edited by exceed
  • Thanks 1
Posted

Hmm  click on image in Acad then CTRL+c, you can then paste in current acad or another dwg, pasting to excel is a different matter.

 

The best for pasting to Word I found to be create a WMF this can be image and linework on top gives a very good result.

 

  • Like 1
  • Thanks 1
Posted
5 hours ago, exceed said:

 

That's my mistake. In order to prevent a lot of unnecessary image files from being created,

I used the method of replacing the image file names with one. 

 

Since the timing of saving the image in Excel is the timing of saving the workbook, the files referenced by the same name before that time become as if the file does not exist. 

 

Therefore, at the beginning of all the code If you fix this line 

            ph  (strcat (getvar "dwgprefix") (vl-filename-base (getvar "dwgname")) ".wmf") ;edited line

like this, 

            ph  (strcat (getvar "dwgprefix") (vl-filename-base (getvar "dwgname")) "-" (rtos (getvar 'cdate) 2 10) ".wmf") ;edited line

there should be no problem. Unless you shoot twice in 0.0001 second.

 

i edited original post

I tried to manually insert a picture in excelc, save it, then delete the original picture, and then open the table and the picture still displays normally. But insert pictures through lsp code - delete the original picture - save the table, open the table again and the picture cannot be displayed. It's weird. Here is my code for recording the macro:

 

Sub vv()
'
' vv vv
'

'
    ActiveSheet.Pictures.Insert( _
        "C:\Users\Administrator\Desktop\Drawi11ng111111.wmf").Select
End Sub

 

Posted (edited)
1 hour ago, ekko said:

I tried to manually insert a picture in excelc, save it, then delete the original picture, and then open the table and the picture still displays normally. But insert pictures through lsp code - delete the original picture - save the table, open the table again and the picture cannot be displayed. It's weird. Here is my code for recording the macro:

 

Sub vv()
'
' vv vv
'

'
    ActiveSheet.Pictures.Insert( _
        "C:\Users\Administrator\Desktop\Drawi11ng111111.wmf").Select
End Sub

 

 

because that Excel Image is linked image.

like .dwg file's xref.

so, for put that images in .xlsx file, 

you have to cut images (ctrl+x) by object select, 

and then paste special (ctrl+shift+v) that. then select png format. 

even if original file is wmf it's ok

 

but in this case image file merged. 

so maybe have to make it this in excel vba.

 

and then you can test, "is this image is really inside of xlsx?"

change .xlsx extension to .zip

and then open it, xl > media 

if it has that images. it is inside of xlsx file.

 

Edited by exceed
Posted (edited)
28 minutes ago, exceed said:

 

because that Excel Image is linked image.

like .dwg file's xref.

so, for put that images in .xlsx file, 

you have to cut images (ctrl+x) by object select, 

and then paste special (ctrl+shift+v) that. then select png format. 

even if original file is wmf it's ok

 

but in this case image file merged. 

so maybe have to make it this in excel vba.

 

and then you can test, "is this image is really inside of xlsx?"

change .xlsx extension to .zip

and then open it, xl > media 

if it has that images. it is inside of xlsx file.

 

I found some information, it is said that this problem will only exist after MS excel 2010, maybe using the 'AddPicture method can solve this problem, but I don't know vba, I don't know how to implement it in lisp, this is an example :http://docs.microsoft.com/ko-kr/office/vba/api/excel.shapes.addpicture

Edited by ekko
Posted (edited)
13 minutes ago, ekko said:

I found some sources, it is said that using the 'AddPicture method can solve this problem, but I don't know vba and don't know how to implement in lisp, here is an example https://docs.microsoft.com/ko-kr/office/vba /api/excel.shapes.addpicture

 

i don't have enough time to see that.

but this will make it linked image to inside attached image. in excel

about 1 workbook all sheets all images

 

Sub attachlinkedimage()
    On Error Resume Next
    Dim shtNo As Integer
    Dim i As Integer
    Dim j As Integer
    Dim wks As Worksheet
    Dim shpC As Shape
    Dim picLeft As Single
    Dim picTop As Single
    Application.ScreenUpdating = False
    shtNo = ActiveSheet.Index
    For i = 1 To Sheets.Count
        Sheets(i).Activate
        For Each shpC In Sheets(i).Shapes
            If shpC.Type = 11 Then
                picLeft = shpC.Left
                picTop = shpC.Top
                shpC.Cut
                ActiveSheet.PasteSpecial Format:="Picture (PNG)", Link:=False, DisplayAsIcon:=False
                Selection.Left = picLeft
                Selection.Top = picTop
                MsgBox j & "th image converted ok"
                j = j + 1
            End If
        Next shpC
    Next i
    MsgBox "Complete"
    Sheets(shtNo).Activate
End Sub

 

alt+f11 and add module and paste it

and run that macro in alt+f8

 

 

+

The "Pictures (PNG)" part of this code is affected by the language setting of Excel. 

Actually "Pictures (PNG)" doesn't work in my language. 

I can't prepare for all languages, so to apply this to excel in other languages 

1. Turn on macro recording. 

2. ctrl+c the image, ctrl+shift+v, select the png format and paste it. 

3. Stop recording the macro and 

4. In the code view at alt+f11, check which word is included in this part. 

5. Replace this code with that word.

Edited by exceed
  • Thanks 1
Posted
1 minute ago, exceed said:

 

i don't have enough time to see that.

but this will make it linked image to inside attached image. in excel

about 1 workbook all sheets all images

 

Sub attachlinkedimage()
    On Error Resume Next
    Dim shtNo As Integer
    Dim i As Integer
    Dim j As Integer
    Dim wks As Worksheet
    Dim shpC As Shape
    Dim picLeft As Single
    Dim picTop As Single
    Application.ScreenUpdating = False
    shtNo = ActiveSheet.Index
    For i = 1 To Sheets.Count
        Sheets(i).Activate
        For Each shpC In Sheets(i).Shapes
            If shpC.Type = 11 Then
                picLeft = shpC.Left
                picTop = shpC.Top
                shpC.Cut
                ActiveSheet.PasteSpecial Format:="Picture (PNG)", Link:=False, DisplayAsIcon:=False
                Selection.Left = picLeft
                Selection.Top = picTop
                MsgBox j & "th image converted ok"
                j = j + 1
            End If
        Next shpC
    Next i
    MsgBox "Complete"
    Sheets(shtNo).Activate
End Sub

 

alt+f11 and add module and paste it

and run that macro in alt+f8

Set myDocument = Worksheets(1) 
myDocument.Shapes.AddPicture _ 
    "c:\microsoft office\clipart\music.bmp", _ 
    True, True, 100, 100, 70, 70

Just need to translate this code into lisp code, thanks a lot my bro

Posted

A command example (vlax-invoke-method mySheet "Activate") so for current sheet make it active. vlax-invoke-method.

 

So maybe these no idea if they will work not tested.

(vlax-invoke-method mySheet  "PasteSpecial")

(vlax-invoke-method mySheet  "Format" "Picture (PNG)")

(vlax-invoke-method mySheet  "Link" :vlax-false)

(vlax-invoke-method mySheet "DisplayAsIcon" :vlax-false)

 

Missing the cell address ? Or one way around is to do a (alert "pick cell in excel") Acad will sit there waiting while you pick a cell in excel, then go back to acad and click OK to continue, I know this works for select range. Not sure if paste will work ok hopefully yes. 

  • Like 1
  • Thanks 1

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