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

Use this space to ask how to do whatever you're trying to use SolidWorks to do.
Jacomuller
Posts: 47
Joined: Wed Mar 01, 2023 6:55 pm
Answers: 2
x 33
x 4

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

Unread post 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?
by Jacomuller » Sun Aug 04, 2024 5:01 pm
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 ><
Go to full post
Jacomuller
Posts: 47
Joined: Wed Mar 01, 2023 6:55 pm
Answers: 2
x 33
x 4

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

Unread post 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?
Jacomuller
Posts: 47
Joined: Wed Mar 01, 2023 6:55 pm
Answers: 2
x 33
x 4

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

Unread post 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.
User avatar
SPerman
Posts: 2056
Joined: Wed Mar 17, 2021 4:24 pm
Answers: 14
x 2227
x 1878
Contact:

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

Unread post by SPerman »

-
I may not have gone where I intended to go, but I think I have ended up where I needed to be. -Douglas Adams
Jacomuller
Posts: 47
Joined: Wed Mar 01, 2023 6:55 pm
Answers: 2
x 33
x 4

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

Unread post 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 ><
Post Reply