Page 1 of 1

Copy a view from one drawing to a view in a new drawing with VBA

Posted: Tue Jul 30, 2024 12:30 am
by Jacomuller
I want to automate one of our shop floor papers. We have a 1 page document with a drawing of an assembly in the top left.

I want the macro to list all the parts with some detail from the custom properties of each part. There must also be a single view drawing with some production related information.
image.png
The way it work is, you drop an assembly on the blank form. By clicking the macro button, it will create all the views, populate all the notes with the custom property info and lastly, it copies a view named "MW" from each part drawing and copy it to the correct view on this sheet.

I have done the part where I get all the views populated with the text data. I also know the full path and file name for the drawing of each part. I also know the name of the View I am interested in. I also know the name of the view in this drawing where I need to copy the drawing to.

Any hints as to where to start with this?

Re: Copy a view from one drawing to a view in a new drawing with VBA

Posted: Tue Jul 30, 2024 7:02 pm
by Jacomuller
Maybe my approach was wrong. I have written the macro to create predefined views which I was hoping to be able to be updated with a view from a part drawing. Since I have the name of the drawing, the full path of the drawing file and the the name of the view, Maybe I should have tried to copy the required view directly to this drawing - is that possible?

Copy a view from one drawing to a view in a new drawing with VBA

Posted: Thu Aug 01, 2024 7:16 pm
by Jacomuller
I have now manage to get the macro running to open a specific drawing, activate a specific sheet and copy a selected view, close the drawing and paste the selection in the current drawing. The issue now is that the new drawing view is not pasted in the correct position.

Earlier in the Macro, I create predefined views to add some notes in. The position of the predefined are placed in the correct location with a x and y position. How do I align the drawing view to an existing view OR is there some wrong with my sheet scale.

Re: Copy a view from one drawing to a view in a new drawing with VBA

Posted: Fri Aug 02, 2024 7:04 am
by SPerman

Re: Copy a view from one drawing to a view in a new drawing with VBA

Posted: Sun Aug 04, 2024 5:01 pm
by Jacomuller
SPerman wrote: Fri Aug 02, 2024 7:04 am See if this helps.

https://help.solidworks.com/2018/englis ... ple_VB.htm
Thanks, I got enough info from that sample to get my code to past the new view where I want it. Thanks again ><