hi, I need to change the dimension in orthogonal views in SLDDRW file without affecting its part using VB. Is it possible to do it? I have attached image indicating what has to be changed.Thanks in advance.
You can change the <DIM> to any text value you need.
I have recorded macro for changing the dimension and when it has been ran, its not refreshing. could u send me the coding for changing the dimension?
Prasanth Kumar Jun 11, 2017 10:45 AM (in response to Deepak Gupta)
i Have a doubt. This program stores the drawing with same name in respective directory. I need to run this code from excel. It shows an error. Could u help me?
Dim FileName As String
Dim swExportPDFData As SldWorks.ExportPdfData
Dim swModel As SldWorks.ModelDoc2
Dim swApp As SldWorks.SldWorks
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
swModel.Save3 0, 0, 0
'Checks to make sure current file is a drawing
If swModel.GetType = swDocDRAWING Then
'Gets current file name and path
FileName = swModel.GetPathName
'strips solidworks extension off name and replaces with pdf
FileName = Left(FileName, Len(FileName) - 6) & "pdf"
'message box line used to confirm modified file name
'sets current pdf export options
Set swExportPDFData = swApp.GetExportFileData(1)
'saves drawing as pdf
swModel.Extension.SaveAs FileName, 0, 0, swExportPDFData, 0, 0
MsgBox "Current File is not a Drawing"
Please do not mix up threads and post repetitively, this would not help you and others.
We are basically obliged to ask: why would you do that? If you save that file with an overridden dimension, you would just create confusion for the next person that sees it.
My task is like that. I have same arrangement with only the dimensions changing. I need to create many files with same arrangements but different dimension.( note : The drawings are in not to scale so i have to just overwrite it without changing the size.)
Create a multi configuration part with different dimension you need and just activate that configuration in the drawing using VBA. This way it won't create any confusion if someone looks at the drawing or part.
It has numerous parts. It is not possible to create numerous parts manually. So only i need a macro just to change the dimensions of the parts which makes me easier to create same parts with numerous dimensions
You should be able to record the macro and execute that. Should be only 5-6 lines of the codes.
Here is how the macro would look like and you would have to change the text/value which I've highlighted in yellow below.
I have recorded the macro. But when it has been run, The dimension is changed only in dimension dialog box and not outside.
Works fine for me. Share your files and the macro you're using.
This is the recorded macro to change the dimension. I dont know how to attach the file here. i have already attached the file in the question session. (CUBE.SLDDRW)
Do not double click on the dimension to change it. Just change it under Dimension Text while recording the macro.
Check #18 of Forum Posting on how to attach files while replying to a post.
Thanks a lot!
How about a design table? You can create configurations and specify dimensions lot quicker in design table then typing values manually.
You would like to change dimension in drawings for different part numbers, so I guess you have this information somewhere in some sort of table format. If this is in excel sheet, then you can just copy and paste these values in design table and create configuration very quickly. It also makes it lot easier if you will need to add or update any configurations in future.
Hope this helps.
hi, i have another doubt . What are the options available to automate the assembly process in solidworks?
Few options could be:
DriveWorksXpress (a free tool with every seat of SOLIDWORKS and can be located under Tools menu) or
Auto-Configure (free trial available)
Configuration publisher (SW inbuilt tool)
Macro (you'll have to make one for your needs)
Which is the easiest method for the new beginner who has to complete in a short span of time?
When i use the solidworks code in excel vba(with refernces to solidworks library) still i have to change any codes?
Depends on lot of factors like what kind of automation, complexity, number of components, options needed, etc.
i had gone through all this options except macros but what i have found is that this options are to create multiple assembly components with different dimension.is it right? i have many varieties of components. I need corresponding component to be fetched and assembled based on the rules . for this purpose which is the right one?
I do agree with Nilesh in using a design table that allows you to configure all the dimensions for each different part numbers.
Anyway, consider that when you modify dimension using macros, you might need to rebuild to see changes, or, better, you can use the boolean function ForceRebuild3 in your macro.
I wrote two simple macros.
The first one gets the value of the selected dimension on the drawing and override it putting the new value.
The second one gets the value of each dimension on each view in the active drawing document and override it with a new value.
The value taken from the dimension is in meters, even if in my document is set in mm - I don't know why!!
Those wok fine for me, I've got Solidworks 2015.
I hope this will help you.
hi, Thanks, i'ill go through it.
Retrieving data ...