Macro recording in PDF and DXF in an external folder

Hello everyone and Happy New Year 2014!

 

I'm looking for a macro that allows:

  • Save an SW setup in DXF and PDF
  • in a folder on the network other than the location of the . SLDDRW
  • Add the custom "Revision" property to the end of the file name
  • click on an icon to do the whole operation

 

The link (http://forum.solidagora.com/macro-api-solidworks-enregistrer-pdf-dxf-x-t101.html) that Gt22 proposed in the question (http://www.lynkoa.com/forum/3d/macro-d-enregistrement-en-pdf#) is a nice promise but there is no macro...

The BatchConverter utility is good but a bit heavier (I just want to have to click on an icon)

 

So, can someone help me?

 

Thank you in advance,

Thomas

Hello

In the solidagora link, it is marked that you just have to contact the person who posted the message to receive the macro. So I'll start there;) 

In the same spirit as BATCHCONVERTER there is INTEGRATION (especially if you want to change the name of the final file by adding the Revision property, because it doesn't seem to me that Batch knows how to do it).

 

You should ask the "DEV" at Axemble if he can create a "macro" for you from SW which launches INTEGRATION with your conversion + modification of the final file settings.

 

Personally, before switching to EPDM, we used BATCHCONVERTER to automatically convert MEPs to dxf, pdf and edrw in a directory other than those of the BEM (so that they would be accessible for production for example).

We launched the BATCHCONVERTER utility every evening which took into account all the drawings made or modified during the day (you manage this via the filters on the dates). The advantage is that there is no oversight, by this method, unlike your macro button which requires human intervention.

2 Likes

If I'm not mistaken, you should ask Lucas Prieur, he knows a lot about macro, but I don't know if he's available?

1 Like

Hello and Happy New Year to all,

 

Indeed I made a similar macro (PDF & DWG).

I was planning to post this one on Lynkoa but I didn't do it due to lack of time. Before posting it, I wanted to simplify it and comment on all the lines one by one for more readability for the neophytes of VBA programming.

 

Do you have the basics in VBA? Do you already have a base for this macro or are you starting from scratch?

 

I've created a tutorial for "Save-As" for SolidWorks (which is simpler and commented on for each line) that you can find here:

http://www.lynkoa.com/tutos/3d/macro-enregistrer-sous-avec-solidworks

 

You'll already have some leads. I'm currently on vacation until the 6th, so I'll transfer the macro at that time (but be aware that this one is specific to our company and will require a lot of adaptation work).

Hello and Happy New Year,

Can you specify when you say:

  • in a folder on the network other than the location of the . SLDDRW

Do you always want it in one place?

 

 

We have our solidworks files (parts, assemblies and drawings) in a "Technical" folder.

We have a "database" of plans in DXF and PDF (searchable by all) in another folder.

 

So NO, these are 2 different places!

But is it a single folder for all PDFs? Or for each order/deal/machine, it's a different folder?

Hi @ ThomasM

 

I think the promise is not only beautiful

since if I'm not mistaken, you were able to recover this said Macro

 

Have you tried it and does it correspond to your real need

 

It is true that the clearer the question, the more targeted the answer is (Lucas) ;-)

 

@+ ;-)

It is indeed a single folder for all PDFs. (and DXF)

No, for the moment it doesn't work.

 

I actually got the macro on the "Solidagora" forum.

But it gives me an error.

A problem related to the fact that I am in 64 bits. (as far as I understand)

 

I try to move forward to make it work.

 

And I'd also like to simplify it so that by pressing the macro icon it does what I ask it to do without having to enter a folder path or check the extension...

 

  

For the 64 bits the only problem I know is that when you launch the macro, the dialog box does not appear.
With a "small" ALT + TAB, you bring up the dialog  box (no need for all those longPtr and PrtSafe ...) 

 

This answer doesn't answer your question

Patient self most people are on end-of-year leave it's going to come

@+ ;-)

Can you post the macro here as a text file?

I can modify it to include the path you want if you give it to me (in UNC it's better, like: "\\SERVER\Design Office\SolidWorks Plans\PDF Plans\")

 

When you have the error, and you click on debuggage, which line do you get to?

See this link

 

https://forum.solidworks.com/thread/66010

 

Attachment

 

@+ ;-)


file_save_as_pdf__dwg.swp_.zip

See this link also

 

http://forum.solidagora.com/topic1758.html

 

@+ ;-)

Here's what I managed to do by recovering right and left.

 

Option Explicit
Public Enum swDocumentTypes_e
    swDocNONE = 0       ' Used to be TYPE_NONE
    swDocPART = 1       ' Used to be TYPE_PART
    swDocASSEMBLY = 2   ' Used to be TYPE_ASSEMBLY
    swDocDRAWING = 3    ' Used to be TYPE_DRAWING
 
End Enum
Dim swApp As Object
Dim swModel As ModelDoc2
Dim sPathName As String
Dim sReference As String
Dim sSaveName As String
Dim longstatus As Long
Dim myRev As String
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc

If swModel Is Nothing Then
    MsgBox ("No open document")
ElseIf swModel.GetType <> 3 Then
    MsgBox ("This is not a drawing")
Else
   sPathName = swModel.GetPathName' retrieves the display name of the current document
   sReference = Mid(sPathName, InStrRev(sPathName, "\") + 1) 'Retrieves everything after the last \
   sReference = Left(sReference, Len(sReference) - 7) 'Removed the 6 characters corresponding to the file extension and the .
   sPathName = Left(sPathName, InStrRev(sPathName, "\")) 'Retrieves path without filename

'myRev = swModel.CustomInfo2("", "Hint") 'Retrieves the hint from the document properties
myRev = swModel.GetCustomInfoValue("", "Index")

   longstatus = swModel.SaveAs3("X:\" + sReference + myRev + ".PDF", 0, 0)
   longstatus = swModel.SaveAs3("X:\" + sReference + myRev + ". DXF", 0, 0)
    
End If


End Sub

 

 

 

Last small problem:

I can't get the "Hint" property that is linked to the part.

swModel.CustomInfo2("", "Index") and swModel.GetCustomInfoValue("", "Index") don't return anything to me.

 

What do I need to write to retrieve the "Index" property?

 

And so, no one is able to tell me how to retrieve the custom "Review" property that is "anchored" in the room?

 

It would be great since it would allow me to fully answer my question!

 

Thank you in advance, then!

I think that on the other forum you have a request for an explanation, see the attached text

 

by annwn » Tue 7 Jan 2014 14:25

Wow... Hold on... I don't understand everything!
What modification of the code did you make?

Can you take screenshots of your error messages?

 

@+ ;-)

Hello

 

I have a similar macro that retrieves a custom property and appends it to the filename.

 

It does what you want, saves a drawing in PDF and DXF with the addition of the "index" property

 

All you have to do is change the destination paths.

 

If you need help, don't hesitate


dxf__pdf_bon_pour_fab.swp
1 Like

To retrieve a custom property, you must use the following command:

Get4 Method (ICustomPropertyManager)

 

Below is the example of the API help:

 

Dim swApp As SldWorks.SldWorks

Dim swModel As ModelDoc2

Dim swModelDocExt As ModelDocExtension

Dim swCustProp As CustomPropertyManager

Dim val As String Dim valout As String

Dim bool As Boolean

 

Sub main()

 

Set swApp = Application.SldWorks

Set swModel = swApp. ActiveDoc

Set swModelDocExt = swModel. Extension

 

' Get the custom property data

Set swCustProp = swModelDocExt. CustomPropertyManager("")

bool = swCustProp. Get4("Property_Name", False, val, valout)

 

Debug.Print "Value: " & val

Debug.Print "Evaluated value: " & valout

Debug.Print "Up-to-date data: " & bool

 

End Sub