Reply

Add jpg logo in a Draft template.

[ Edited ]

Hi,

 

Just wondering if anyone could help. I try to add a logo on a drawing, this logo is located on "C:\blabla\LOGO.JPG"

---------------------------------------------------------------------------------------------

     Dim LinkPicture as string="C:\blabla\LOGO.JPG"

 

     Dim TargetobjImage2ds as SolidEdgeFrameworkSupport.Images2d = Nothing

     Dim TargetobjImage2d As SolidEdgeFrameworkSupport.Image2d = Nothing

 

        Try       

 

  TargetobjImage2d = TargetobjImage2ds.AddImage(vbTrue, LinkPicture)

 

        Catch ex As Exception

            MsgBox(ex.Message & "_AddImage2d")          

        Finally

            Call unrelease(TargetobjImage2ds)

           Call unrelease(TargetobjImage2d)

        End Try

 

-------------------------------------------------------

 

I got an error message : HRESULT 8000:4002.Have you an idea ?

 

thanks a lot

DD

 

 

 

 

Posted by: dd dd
Post date: 7/22/2011 5:00:46 AM

4 REPLIES

RE: Add jpg logo in a Draft template.

[ Edited ]

DD,

 

you have to add a SmartFrame2d object to the SmartFrames2d collection of a Sheet object of the draft document object by using either the methods AddBy2Points or AddByOrigin of the SmartFrames2d collection object. Then you use the methods CreateEmbed or CreateLink of the just added SmartFrame2d object. CreateEmbed or CreateLink takes as argument the pathname to the OLE object (jpg file in your case) and the type of the OLE object.

 

BTW - To use a jpg logo is almost not to be recommended from the standpoint of output quality and draft exporting issues.

 

 

Posted by: Wolfgang Kunert
Post date: 7/22/2011 9:38:54 PM

RE: Add jpg logo in a Draft template.

[ Edited ]

Thanks a lot for your reply,

 

But What do you advice me as logo format ? (tiff ?)

 

On SDK I don t arrive to find what I have to write and choose as ole object and Style name...(I am sorry I have just to start SolidEdge programming)

 

Dim LinkPicture as string="C:\blabla\LOGO.JPG"

 

TargetobjFrame2d = TargetobjFrame2ds.AddBy2Points(StyleName:=????, x1:=0, y1:=0, x2:=25, y2:=25)

TargetobjFrame2d.CreateEmbed(SourceDoc:=LinkPicture, ObjectType:=????)

 

I have to import a Namespace ?

 

Thanks a lot,

 

DD

 

 

 

 

 

 

 

 

 

 

Posted by: dd dd
Post date: 7/24/2011 9:21:34 PM

RE: Add jpg logo in a Draft template.

[ Edited ]

The SDK help says:

 

 

Parameters

SourceDoc

Type: System..::..Object

Specifies the file name of the document to be used as a template for the embedded object. If not specified, the embedding will be created from a new object. Creating a new object will automatically launch the application associated with the new object's type.

ObjectType

Type: System..::..Object

Specifies the name of the OLE object type of the embedded object. Not needed if SourceDoc is specified, but required if SourceDoc is not specified.

 

 

I meant embedding a bitmap for a logo etc at all is not recommended. It's better to redesign a logo by use of just native Solid Edge elements like lines, arcs, curves etc.

 

 

Posted by: Wolfgang Kunert
Post date: 7/24/2011 9:58:00 PM

RE: Add jpg logo in a Draft template.

[ Edited ]

 

I'm also trying to put a .jpg file on a drawing working sheet. I have SE open, and at the onset I have a model open, and

also a draft file's workin sheet open beneath the model.

I first store the image of the model in a .jpg file, then make the Draft active and try to put the image on the worksheet.

 

The code is :

 

Private Sub cmdDo_Click()

Dim objapp As SolidEdgeFramework.Application

Dim objDoc As SolidEdgeFramework.SolidEdgeDocument

Dim objDraftDoc As SolidEdgeDraft.DraftDocument

Dim smartfrms As SolidEdgeFrameworkSupport.SmartFrames2d

Dim smartfrm As SolidEdgeFrameworkSupport.SmartFrame2d

Dim objsheet As SolidEdgeDraft.Sheet

Dim objWindow As Window

 

   Set objapp = GetObject(, "SolidEdge.Application")

   Set objDoc = objapp.ActiveDocument

 

   Set objDraftDoc = objapp.Documents(2)

   Set objWindow = objDoc.Windows.Item(1)

 

   objWindow.View.SaveAsImage ("C:\Customers\imagetest\sprocket.jpg")

 

   objDraftDoc.Activate

   Set objsheet = objDraftDoc.ActiveSheet

   Set smartfrms = objsheet.SmartFrames2d

   Set smartfrm = smartfrms.AddByOrigin("", 0#, 0#, 1#, 0#, 0#, 3#)

   Call smartfrm.CreateEmbed("C:\Customers\imagetest\sprocket.jpg")

 

   Stop

 

End Sub

 

Trouble is that instead of getting the image on the draft sheet, I'm getting

a rectangle and in it THE NAME OF THE JPG FILE.

 

If manually, I just drag-and-drop the jpg file upon the draft sheet, I'm getting

THE IMAGE of it - just what I need.

 

What's wrong ??!

 

BTW - this is an addition to an existing VB6 program - so it's also in VB6...

 

Thanks for any help ?

 

Posted by: Oswald Baruch
Post date: 7/27/2011 9:04:29 PM