Can anybody help me on populating file properties of nearly 25 drawing (all at a time like by using task scheduler) into excel as i want to cross varify.
Search for Batch Macro Runner or Batch Macro Runner Lite in myIntercad.myToolkit
You can download the myIntercad for free at this link: http://intercad.com.au/myintercad/
This allows running any macro on a files within a folder.
Artem Taturevych, Application Engineer at Intercad (Australia)
translationXpert – add-in to translate SolidWorks models
myIntercad – an integrated tool for SolidWorks Professionals
LinkedIn SolidWorks API Education Group
I tried but not able to find out any suitable one, it will be your gratitude if you could get for me with your time.
Did you check the macro/post link I shared here: https://forum.solidworks.com/message/374725#374725
Yes, I have checked and trying to modify below macro for getting all file properties in excel sheet.
I am able to get first raw with all file properties heading, now I stuck at how to read its respective value like for its description or material etc.
I have added BOLD LETTERS shown below but showing some object error.
Request to help.
Dim swApp As SldWorks.SldWorksDim SwModel As SldWorks.ModelDoc2Dim swModExt As SldWorks.ModelDocExtensionDim swAssembly As SldWorks.AssemblyDocDim SwComp As SldWorks.Component2Dim MassProp As SldWorks.MassPropertyDim Component As VariantDim Components As VariantDim Bodies As VariantDim BodyInfo As VariantDim CenOfM As VariantDim RetBool As BooleanDim RetVal As LongDim xlApp As Excel.ApplicationDim xlWorkBooks As Excel.WorkbooksDim xlBook As Excel.WorkbookDim xlsheet As Excel.WorksheetDim OutputPath As StringDim OutputFN As StringDim xlCurRow As Integer Sub main()Set swApp = Application.SldWorksSet SwModel = swApp.ActiveDoc
If SwModel Is Nothing Then swApp.SendMsgToUser2 "An assembly must be an active document.", swMbWarning, swMbOk Exit Sub End If If SwModel.GetType <> swDocASSEMBLY Then swApp.SendMsgToUser2 "An assembly must be an active document.", swMbWarning, swMbOk Exit Sub
Set swAssembly = SwModel
Set swModExt = SwModel.ExtensionSet MassProp = swModExt.CreateMassPropertyOutputPath = Environ("USERPROFILE") & "\Desktop\"OutputFN = SwModel.GetTitle & ".xlsx"If Dir(OutputPath & OutputFN) <> "" ThenKill OutputPath & OutputFNEnd IfSet xlApp = Excel.ApplicationxlApp.Visible = TrueSet xlWorkBooks = Excel.WorkbooksSet xlBook = xlWorkBooks.Add()Set xlsheet = xlBook.Worksheets("Sheet1")xlsheet.Range("A1").Value = "Component"xlsheet.Range("B1").Value = "X Loc (mm)"xlsheet.Range("C1").Value = "Y Loc (mm)"xlsheet.Range("D1").Value = "Z Loc (mm)"xlsheet.Range("E1").Value = "Mass (kg)"xlsheet.Range("F1").Value = "Type"xlsheet.Range("G1").Value = "Description"xlsheet.Range("H1").Value = "Material"
xlBook.SaveAs OutputPath & OutputFNxlCurRow = 2RetVal = swAssembly.ResolveAllLightWeightComponents(False)Components = swAssembly.GetComponents(False)For Each Component In Components Set SwComp = Component If SwComp.GetSuppression <> 0 Then 'If LCase(Right(SwComp.GetPathName, 3)) <> "asm" Then Bodies = SwComp.GetBodies2(0)'MsgBox SwComp.Name 'If Bodies <> Empty Then RetBool = MassProp.AddBodies(Bodies) CenOfM = MassProp.CenterOfMass xlsheet.Range("A" & xlCurRow).Value = SwComp.Name xlsheet.Range("B" & xlCurRow).Value = CenOfM(0) * 1000 xlsheet.Range("C" & xlCurRow).Value = CenOfM(1) * 1000 xlsheet.Range("D" & xlCurRow).Value = CenOfM(2) * 1000 xlsheet.Range("E" & xlCurRow).Value = MassProp.Mass xlsheet.Range("G" & xlCurRow).Value = GetDefaultConfigProps(SwComp, "Description") xlsheet.Range("H" & xlCurRow).Value = GetDefaultPartProps(SwComp, "Material") If LCase(Right(SwComp.GetPathName, 3)) = "asm" Then xlsheet.Range("F" & xlCurRow).Value = "Assembly" ElseIf LCase(Right(SwComp.GetPathName, 3)) = "prt" Then xlsheet.Range("F" & xlCurRow).Value = "Part" Else xlsheet.Range("F" & xlCurRow).Value = "Undetermined" End If 'Right 3 of file extension xlCurRow = xlCurRow + 1 'End If 'UBound(Bodies) <> -1 'End If 'Not an Assembly End If 'swComp.GetSuppression <> 0Next Component
Try the attached macro and modify as required (works only for Drawing files).
I am having some issues in trying to get my properties from my draw model to link into an object (excel spreadsheet). If you have a suggestion, I would appreciate to hear about this, Ben Klose
Ben, sorry but I've no idea if it is possible to have the properties linked/populated to embedded excel file in SolidWorks.
Ben, you'll simply need to run the macro (that updates the Excel spreadsheet) every time you save the part. You might consider using an equation-triggered macro to accomplish this.
SolidWorks API Video Tutorials
I am having an issue inserting the .swp into the drawing. Any questions/help?
My apologies, I did not realize you were using a drawing. I see now that you did say "draw model".
You can't use equation-triggered macros with drawings because drawings do not have equations. If you still want the macro to run automatically, you can have the macro run on startup. This blog post says in point #2 how to run a macro on SolidWorks startup.
I guess I need to know the best way to link the custom properties to the inserted object (excel). The reason it needs to be an object is all the functions within the excel sheet. These items are not shown as available in a general table. If I could set it up in this table, then my draw sheet would be done.
If the height, width, length, parts, part weight, rack weight, tier one engineer and company would be inserted from the custom properties then it would solve
Meaning that everytime that this start model is used, as soon as the rack base was changed then this table on sheet one would always be accurate
If need be, is there a way I could send you this excel file to show you what I am looking for?
I have used your macro. Its working only for part name and description only but not filling my other tabs like material, etc.
The macro works for drawings only. Do you need to run the macro on parts. If yes what properties you're looking to extract from the part. If you can attach one sample file containing all the properties you need to extract, then I can modify the macro to suit your needs.
Please use "advanced editor" in case you want to attach any files.Click on reply and then click "use advanced editor".
Here is the snap of proprerties that i need to capture.
Is there any opertunity to have this kind of macro for parts ??
The reason you were not getting those properties because macro has different properties listed.
Now before I modify the macro let me know if you need the macro for part OR drawing OR both??
Need for both,
This snap is for drawing only.
Check the attached picture and modify the macro accordingly for your need for parts, assemblies and drawings.
Thanks a lot deepak.
Its very much useful...
I'm starting to study this subject, so I don't know almost anything about it.
I would appreciate if someone could suggest me some sites or material that can help me.
Retrieving data ...