×
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

Macro Help

Macro Help

Macro Help

(OP)
A fellow over at solidworks community helped me out and wrote a macro for me.  It's works fine on my work machine but I can't get it to run on my home machine.  I asked for some help over there but no responses.  I was hoping someone here could help.

I get a run time error. See attatchment.

My home rig specs are
SW2009 32 SP 1.0
Home built pc
Nvidia Quadro FX 1100
Core 2 1.8GHZ, 2GB RAM
XP Pro 32 SP2.0

work machine specs are below.

here is the code

Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swDraw As SldWorks.DrawingDoc

 
Dim vConfs As Variant
Dim i As Integer

 
Dim sDrTemplate As String
Dim lDrSize As Long

 
Dim sOutputFolder As String

 
Sub main()
    
    Set swApp = Application.SldWorks
    
    Set swModel = swApp.ActiveDoc
    
    sOutputFolder = Left(swModel.GetPathName(), Len(swModel.GetPathName()) - Len(swModel.GetTitle()) - 7)
    
    sDrTemplate = swApp.GetUserPreferenceStringValue(swUserPreferenceStringValue_e.swDefaultTemplateDrawing)
    lDrSize = swDwgPaperSizes_e.swDwgPaperA0size
    
    vConfs = swModel.GetConfigurationNames()
    
    For i = 0 To UBound(vConfs)
        
        Set swDraw = swApp.NewDocument(sDrTemplate, lDrSize, 0, 0)
        swDraw.Create1stAngleViews2 swModel.GetPathName
        Dim swView As SldWorks.View
        Set swView = swDraw.GetFirstView
        
        While Not swView Is Nothing
            
            swView.ReferencedConfiguration = vConfs(i)
            
            Set swView = swView.GetNextView
            
        Wend
        
        Dim swDrawModel As SldWorks.ModelDoc2
        Set swDrawModel = swDraw
               
        swDrawModel.ForceRebuild3 False
        
        swDraw.InsertModelAnnotations3 swImportModelItemsSource_e.swImportModelItemsFromEntireModel, 32776, True, True, False, False
                
        swDrawModel.Extension.SaveAs sOutputFolder + swModel.GetTitle() + "_" + vConfs(i) + ".slddrw", swSaveAsVersion_e.swSaveAsCurrentVersion, swSaveAsOptions_e.swSaveAsOptions_Silent, Nothing, 0, 0
        
        swApp.CloseDoc swDrawModel.GetTitle()
        
    Next
    
End Sub

 

Certified SolidWorks Associate
SW2009 X64 SP 1.0
Dell Precision T5400
Nvidia Quadro FX 5600
Xeon 2.5GHz Quad Core, 4GB RAM
XP Pro X64 SP2.0
 

RE: Macro Help

Is your other computer a 64-bit?

RE: Macro Help

(OP)
no 32

Certified SolidWorks Associate
SW2009 X64 SP 1.0
Dell Precision T5400
Nvidia Quadro FX 5600
Xeon 2.5GHz Quad Core, 4GB RAM
XP Pro X64 SP2.0
 

RE: Macro Help

Write/Start a new macro on your home machine and copy paste the codes. I'm sure some reference library are missing.

Or

Edit the macro in VB editor. Go to Tools > References and look for missing libraries

Deepak Gupta
SW2009 SP4.1
SW2007 SP5.0
MathCAD 14.0

RE: Macro Help

(OP)
I unistalled and reinstalled hoping that would help.  Same results.

I have checked the ref library and they are the same.

I did copy it to a new macro on my home machine.

Certified SolidWorks Associate
SW2009 X64 SP 1.0
Dell Precision T5400
Nvidia Quadro FX 5600
Xeon 2.5GHz Quad Core, 4GB RAM
XP Pro X64 SP2.0
 

RE: Macro Help

But your signature says your system is 64 bit.

Deepak Gupta
SW2009 SP4.1
SW2007 SP5.0
MathCAD 14.0

RE: Macro Help

(OP)
Work is 64 home is 32.  Both have SW2009 SP1. I tried the copy from work that ran fine and copied the code into a new macro neither worked on my home machine.

The writer of the macro said to check my default drawing template in settings. He thinks it's not getting a drawing template therfore it has a empty drawing.

I will try that when I get home.

Certified SolidWorks Associate
SW2009 X64 SP 1.0
Dell Precision T5400
Nvidia Quadro FX 5600
Xeon 2.5GHz Quad Core, 4GB RAM
XP Pro X64 SP2.0
 

RE: Macro Help

There are issues with VB6 on 64-bit machines.  Something written on a 32-bit machine may not work on a 64-bit machine, and vice versa. I notified the API development team of this issue in person at SolidWorks HQ in August 2009, and they seemed surprized.   

Matt Lorono
CAD Engineer/ECN Analyst
Silicon Valley, CA
Lorono's SolidWorks Resources
Co-moderator of Solidworks Yahoo! Group
and Mechnical.Engineering Yahoo! Group

RE: Macro Help

(OP)
This one was a user error.  I didn't update my default template so the template it was trying to use was not there.  

Works great and is a nice macro.  I'm trying to figure out how to make it populate predefined views of a template.  Once that is ironed out this will be a nice macro for automating simple drawings.

Certified SolidWorks Associate
SW2009 X64 SP 1.0
Dell Precision T5400
Nvidia Quadro FX 5600
Xeon 2.5GHz Quad Core, 4GB RAM
XP Pro X64 SP2.0
 

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