×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Weldment API Problem in Windows 7 x64

Weldment API Problem in Windows 7 x64

Weldment API Problem in Windows 7 x64

(OP)
Hi, I know this is pretty new but I am using solidworks 2009 SP3 in windows 7 Build 7100 and a macro , the same one the api help files shows as an example, stop workind in this windows, even in vista x64 it works, Is there anyone with the same problem or maybe a solution. The code is this one.

thanks.

Option Explicit

 

Dim swApp As SldWorks.SldWorks

Dim swModel As SldWorks.ModelDoc2

Dim swModelDocExt As SldWorks.ModelDocExtension

Dim swSelMgr As SldWorks.SelectionMgr

Dim swWeldFeat As SldWorks.Feature

Dim swWeldFeatData As SldWorks.StructuralMemberFeatureData

Dim boolstatus As Boolean

 

Sub main()

Set swApp = Application.SldWorks

Set swModel = swApp.ActiveDoc

Set swSelMgr = swModel.SelectionManager

Set swModelDocExt = swModel.Extension

boolstatus = swModelDocExt.SelectByID2("Structural Member1", "BODYFEATURE", 0, 0, 0, False, 0, Nothing, 0)

 

Set swWeldFeat = swSelMgr.GetSelectedObject6(1, 0)

Set swWeldFeatData = swWeldFeat.GetDefinition

swWeldFeatData.AccessSelections swModel, Nothing

**************************************************************
it stop working in this line !!!!!!!
**************************************************************

swWeldFeatData.WeldmentProfilePath = "C:\Program Files\SolidWorks_2006_sp0\data\weldment profiles\iso\pipe\26.9 x 3.2.sldlfp"

boolstatus = swWeldFeat.ModifyDefinition(swWeldFeatData, swModel, Nothing)

 

End Sub
 

RE: Weldment API Problem in Windows 7 x64

Did you get an error message when the macro stopped.

RE: Weldment API Problem in Windows 7 x64

(OP)
yes, Error '-2147417851 (80010105)':
Automation Error

RE: Weldment API Problem in Windows 7 x64

A quick Google with those terms shows that error (in some cases) can be corrected by switching to late binding with objects ... whatever that means.

RE: Weldment API Problem in Windows 7 x64

(OP)
I found this too but couldn't understand, i have vista and win7 in the same computer and I tested the code on both, I was looking for a alternative, what i reaaly want is to change the weldment profile, if there is other ways I just need the vb command, the rest i can figure it out. thanks for helping, I tried to record a macro to see how it is done, but if I run the recorded macro it doesn't work..  

RE: Weldment API Problem in Windows 7 x64

When you declare a variable in VBA, you use the statement

Dim [varname] As [vartype]

When you declare an object variable, you can either tell VBA straight up what type of object you expect, like

Dim swApp As SldWorks.Application

or you can let VBA figure it out on its own by declaring like

Dim swApp As Object.

This makes VBA figure out what kind of object it has once it gets it.

If you use the second method, it's called "late binding".  The first method is called "early binding".  Each has its pros/cons.

-handleman, CSWP (The new, easy test)

RE: Weldment API Problem in Windows 7 x64

(OP)
I try to use late binding but the same error apears.. :(

RE: Weldment API Problem in Windows 7 x64

make assembly from your part first

'-------------------------------------------------
'
' Preconditions: Assembly document open that has part with a feature named Structural Member1.
'
' Postconditions: Profile changed to profile specified in macro.
'
'--------------------------------------------------
Option Explicit
 
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swModelDocExt As SldWorks.ModelDocExtension
Dim swSelMgr As SldWorks.SelectionMgr
Dim swWeldFeat As SldWorks.Feature
Dim swWeldFeatData As SldWorks.StructuralMemberFeatureData
Dim boolstatus As Boolean
Dim swComp As SldWorks.Component2
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swSelMgr = swModel.SelectionManager
Set swModelDocExt = swModel.Extension
'select your structural member
Set swWeldFeat = swSelMgr.GetSelectedObject6(1, 0)
Set swComp = swSelMgr.GetSelectedObjectsComponent3(1, 0)

Set swWeldFeatData = swWeldFeat.GetDefinition
swWeldFeatData.AccessSelections swModel, swComp
swWeldFeatData.WeldmentProfilePath = "C:\Program Files\SolidWorks_2006_sp0\data\weldment profiles\iso\pipe\26.9 x 3.2.sldlfp"
boolstatus = swWeldFeat.ModifyDefinition(swWeldFeatData, swModel, swComp)
 
End Sub

  

RE: Weldment API Problem in Windows 7 x64

(OP)
It gives the folowing error.


error '-2147417551 (80010105)':
Automation Error

when trying to execute
swWeldFeatData.WeldmentProfilePath = "C:\Program Files\SolidWorks_2006_sp0\data\weldment profiles\iso\pipe\26.9 x 3.2.sldlfp"

P.S: I changed the Path to a valid one.

Debug.Print Err returned -2147417851

 

RE: Weldment API Problem in Windows 7 x64

I have sw2009 sp4.1

Bdw. is crashing if I change weldment profile path in part doc, but assembly doc is working here without problems.  

RE: Weldment API Problem in Windows 7 x64

(OP)
I Use it to create new parts via API. I open some custom parts eatch with his own drawing already made. I don't see how can I use in assembly this way. The idea is to automate the process of creating parts, it acess a data base to get a newcode and the weldment profiles to change "Base Parts" I already created, is like a shaft frequently used, so my base parts already have keyways and holes, in this process i used to change the profile, now i pause the macro to do it manualy then macro continues from this point, very furstating.. but thanks for the efford, maybe I can find an alternative knowing that in assemblies it work.

RE: Weldment API Problem in Windows 7 x64

if you are creating new part you can also create temporary dummy assembly and put your part in there, for changing profile path and save your part and throw assy away.  

RE: Weldment API Problem in Windows 7 x64

(OP)
humm. I'll gonna try that! I post back here if it worked.

RE: Weldment API Problem in Windows 7 x64

there is also difference between model created in sw2008 and converted to 2009 and new created weldment in 2009. Another property sheet of structural member. Converted is missing groups and is crashing by weldmentprofilepath command.  

RE: Weldment API Problem in Windows 7 x64

(OP)
uhuuuuuuuuuuuuuuuuuuuuuuuu \o/

Yes I am happy and yes there is a conversion problem..
All I have to do is make the base parts again but those are very easy to do...

Thank you a lot!!!!!

:)

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources