Display a Solidworks Model within a API Form

Right now I'm using VB6 because I can bang out the test code quickly.

I need to display a Solidworks model in a form and manipulate the dimensions.  Is there a ActiveX control?  Sample code?

SolidworksApi macros
Answers 16
SB
SB 2016-12-09 Best Answer

Dave, here is an example from the SolidWorks help files using VB.NET.

This might not be exactly what you're looking for, but maybe it will set you in the right direction.  Something tells me you won't be able to actively update your preview using this method, but I could be wrong.

2015 SOLIDWORKS API Help - Get Preview Bitmap of File Example (VB.NET)

CC
CC 2016-12-09

Need to confirm from API experts here

I believe you can capture the image and put on your form but I'm not sure about manipulating the dimension? manipulating: you mean editing the dimension on the image you capture? you can use paint brush to do this but it can't be used back to SW

DP
DP 2016-12-09

Sort of...

I want the user to be able to update a set list of dimensions and have the model update in a control/form window.  Basically, seeing design changes on-the-fly.

CC
CC 2016-12-09

I might be wrong but don't think you can do this (change on the fly)

I can't recall the name but I think SW has some kind of product which your team can share

SB
SB 2016-12-09

Half joking, but how about make your SolidWorks window really small and hide all your toolbars. 

It sounds like you would need to just be running and instance of SolidWorks in order to build and change and view your model dynamically.

CC
CC 2016-12-09

if this is the case, why don't you and your team use free product "go to meeting' for a remote session?

JB
JB 2016-12-09

Dave,

I'm 99% sure the exact thing you're asking for is not possible.  However, you may be able to come close with some combination of DriveWorks, Configuration Publisher, and eDrawings...

JP
JP 2016-12-10

Hi,

If you want to try out a free product with for small assemblies then you can use mine which is shared:-

You only need solidworks knowledge and excel knowledge to create your own configurator. Its free for now, so you can try that out.

Regards,

Jeetendra Prasad

CC
CC 2016-12-10

Thank you for sharing - it's very neat !

JP
JP 2017-04-05

Hi Christian Chu.

Thanks. But I want to know if the tool was useful to you and were u able to create simple software or product configurator for your own need? I need to create this software to professional one, so I am looking for feedback.

Regards,

Jeetendra Prasad

AJ
AJ 2017-04-05

Yes. Edrawings professional has an activex control that you can use to display solidworks models. I've developed an application that does that to someone in my early days in the forums. I'm not sure really about the dimensionning bit but I'm positive on the activex controls.

Edit: You can develop an application that can list the dims and you change them from there. Deployment wise, you'll need SOLIDWORKS and Edrawings Professional installed on the target machine which kinda defeats the point of developing such application unless you're worried about security.

CC
CC 2017-04-05

I just had a quick look and sorry, never have time to play with it so I don't think my feedback is good at this time

CC
CC 2017-04-05

Manipulating the dimension (changing/updating the model  on the fly) is the issue here which I don't think it'd be possible??? Pls. correct me if I'm wrong here???

AJ
AJ 2017-04-06

Well, you bring the dims into a gridview and select the entity when the the associated dim row is selected and vice versa. You can change the dims value, update the model and then re-show in the activex control.

AJ
AJ 2017-04-06

Just wanted to add that my downside to my approach is that it is over-engineered. The only up side to it that it is possible. As you suggested, the op is better is off with a gotomeeting solution or a web model configurator.

DP
DP 2017-11-20

Some time ago I came up with a solution that seems to work well.

(Simplified) Using VB6 (Classic), I have a form that includes a image control and a button.  When the button is clicked a sub routine writes a JPG image of the SolidWorks file, and writes it to a directory with a common name.  After the JPG file has been written, a "LoadPicture" command reloads the JPG file into the image control.

Its cheesy, but it works.

<p>Private Sub cmdNewImage_Click()</p><p></p><p></p><p>  Call modCommon.CreateJPGImage</p><p>  Me.imgMagnet = LoadPicture("H:\Temp\ModelImage.JPG")</p><p></p><p></p><p>End Sub</p>

<p>'---------------------------------------------------------------------------------------</p><p>' Procedure : CreateJPGImage</p><p>' Date      : 07/19/2017</p><p>' Purpose   : Creates a new JPG image for the model preview</p><p>'---------------------------------------------------------------------------------------</p><p>'</p><p>Public Sub CreateJPGImage()</p><p></p><p></p><p>  Dim strImageSavePath  As String</p><p></p><p></p><p>  ' Error handling header</p><p>  On Error GoTo CreateJPGImage_Error</p><p>  Dim strModuleName     As String</p><p>  strModuleName = "Sub.CreateJPGImage"</p><p></p><p></p><p>  Set swApp = CreateObject("SldWorks.Application")</p><p>  Set swModel = swApp.ActiveDoc</p><p></p><p></p><p>  strImageSavePath = "H:\Temp\ModelImage.JPG"</p><p>  swModel.EditRebuild3</p><p>  swModel.ShowNamedView2 "ScreenCapture", -1</p><p>  swModel.SaveAs3 strImageSavePath, 0, 0</p><p></p><p></p><p>  Set swModel = Nothing</p><p>  Set swApp = Nothing</p><p></p><p></p><p>  ' Start error handling exit section</p><p>  On Error GoTo 0</p><p>  Exit Sub</p><p></p><p></p><p>CreateJPGImage_Error:</p><p></p><p></p><p>  modErrorLogFile.WriteToLog "Error Data:" & vbCrLf & _</p><p>             "Number: " & Err.Number & vbCrLf & _</p><p>             "Description: " & Err.Description & vbCrLf & _</p><p>             "Location: " & strModuleName & " - Line: " & Erl</p><p></p><p></p><p>End Sub</p>