Solidworks API Open a Drawing from a Part

Hello

I would like to be able to open a drawing from a room,
I've already managed to do the opposite (Open a room from a drawing), but that's not what I want.

 

Do you have an idea of how to do it? I searched a lot of time on the forum and the Net and I only have to find how to go from "2D --> 3D" and not the other way around.

And logically it should be doable, if from the graphical version of solidworks you can do "Right click --> Open drawing".

 

Thank you
KVuilleumier.

1 Like

Hello

And by doing a macro by learning, what is the code created?

http://help.solidworks.com/2013/french/SolidWorks/sldworks/t_record_pause_macro.htm

 

2 Likes

Hello 

I created a keyboard shortcut to open a drawing from the room.

1 Like

Hello

If the drawing and the part have the same name, we can do so:

In  the part file, in the tree view, at the very top of the part name, right-click and "Open the plan"; The drawing opens.

There you go

6 Likes

Here's how I do it and it works great... There will just be a window that will open to tell you that a drawing exists and if you want to open it


ouvrir_une_mise_en_plan_depuis_une_piece.docx
2 Likes

Hello,

There you go, I tried the 2 ways (manu67 & alain. ERP). It should be noted that I don't work in "Vault" mode.

The manu67 way is equivalent to the "Create a drawing from the part/assembly" function
The disadvantage of this way is that SW does not always find the desired file. Certain conditions must be met. The drawing file must have the same name as the 3D and you must not have opened or saved another file in a different directory just before. If this is the case, SW will open a dialog box offering you to create a new drawing.

Alain's way. ERP is more efficient. The "Open Drawing" function will first check if there is a .slddrw file with the same name in the directory where the 3D file is saved. If it can't find it, SW will search for that file in the directory where it was last saved or opened. And if it still can't find it, it will open a dialog box to choose the desired file. Once this choice is made, the link between the 2 files is NOT fixed . You will have to go through this dialog box again if you repeat this operation.

IN BOTH CASES, IT DOESN'T WORK IF THE DRAWING DOESN'T HAVE THE SAME NAME AS THE 3D FILE.

Wishing you a good day on SW.

1 Like

Hello

I don't think it's possible if you don't have the same name as the play. That's what connects them  to each other...

Otherwise you can right-click on the part and at the top I think it's the 3rd icon "open drawing"

1 Like

Thank you for your answers,
I thought, wrongly, that there was a link between 2D and 3D. I didn't know that solidworks was doing a simple name and folder check.

So I simply checked if a drawing is named the same as the part (which is the case for 99.99% of our parts).

Thank you for your answers!

Hello

 

I'm editing this topic because I want to do the same thing.

It is indeed impossible to make "open the drawing" from a 3D if the 2 files do not have the same name.

However, there is indeed a link between 3D "to" 2D. 

Open the 3D part in question and do "composition to go" you will notice that if you check "Include drawings" it will find its associated 2D, even if they do not have the same name and even if the 2D is not open!

No! No 3D link => MEP.

The takeaway composition scans the folder and sub-folders and looks for where your piece is used...

Try to do a test by moving your MEP to a higher level, when the composition to take away no longer finds the MEP.

On the other hand, there is a MEP = 3D > link so you can scan the folder and subfolders and then for each MEP list its references (without opening the MEP) and look for your file.

Personally I made a code (in vb.net and not in vba) that scans folders and subfolders.

1 Like