I'm inspecting the draft objects(DraftDocument, DrawingView etc) searching for a property or method to insert an image to a draft, like in the picture bellow(selected in pink).
I know it's ought to be simple, but I looked at documentation and Solid Edge Spy, and I couldn't find it.
Does anybody know the code that does that?
Solved! Go to Solution.
I did the opposit, I had to search for an image and had to delete it. Its quite hidden:
To add a new one, you presumably can use (note the plural):
var image = FrameworkSupport.SmartFrames2d.AddBy2Points(StyleName, x, y);
and then modify the options of the SmartFrame2d object.
Hope that helps
Hi, Freijon. Thanks for your response!
I'm having a litle problem with this code. VS complains that an object reference is needed to call the method AddBy2Points as you can see bellow:
When I try to create the object it says that I can't create an instance of this abstract class or interface:
It seems not to make sense creating a custom class that supports this interface and implement this method so that I could instanciate an object and call it.
Sorry if I'm missing something really silly right under my nose.
Any ideas about how I can use the method SmartFrames2d.AddBy2Points() to create a SmartFrame?
Sorry, my code was supposed to be dummy code to explain the situation. What you will have to do is the following (in C# but I'm sure you can translate it yourself):
DraftDocument dft = null;
Sheet sheet = null;
SmartFrames2d sfs2d = null;
SmartFrame2d image = null;
dft = (DraftDocument)app.ActiveDocument; //"app" is the Application object
sheet = (Sheet)dft.ActiveSheet;
sfs2d = (SmartFrames2d)sheet.SmartFrames2d;
image = (SmartFrame2d)sfs2d.AddBy2Points("", 0.5, 1.0, 1.0, 1.5);
Haven't tested the code, but it should work IMO.
Thanks for you code. It really shows the SmartFrame2d, but displaying only the name of the image, as you can see bellow:
I left the Style parameter blank(image = (SolidEdgeFrameworkSupport.SmartFrame2d)sfs2d.AddBy2Points("", 0.0, 0.0, 0.01, 0.3)
I don't know if it's causing the issue. I'm investiganting the SmartFrame2dDefault(s) and SmartFrame2dStyle(s), but wiht no success until now. If I have any news I'll post here.
I finally did it! It's similar to your solution! The sheet class has an image2D object.
SolidEdgeFrameworkSupport.Images2d imgs = null; SolidEdgeFrameworkSupport.Image2d img = null; imgs = sheet.Images2d; img = imgs.AddImage(true, @"C:\Detail.png"); img.Update();
Thanks a lot for your help!
Thanks for you code.
I used your code：
SolidEdgeFrameworkSupport.Images2d imgs = null;
SolidEdgeFrameworkSupport.Image2d img = null;
imgs = sheet.Images2d;
img = imgs.AddImage(true, @"C:\Detail.png");
but I get a error message: Operation aborted (Exception from HRESULT: 0x80004004 (E_ABORT)).
I don't know if it's causing the issue.
If you are convenient, please help me.
If there is no difference for you, try to embed the image in the draft by using "false" as first parameter.
Trying to link any file of type BMP, PNG, JPG (I did not try more) in ST10 MP6 gives me an "MK_E_INVALIDEXTENSION" exception!