Retrieving a Model Property Contained in MeP

Good evening, to improve a macro of drawing  recording in pdf, I would like to recover a property of the part contained in the drawing. I specify that this property is not in the slddrw file.
If some; someone can help me, I couldn't find anything on the forum, thank you in advance.

 

Hello fifounet44,

Are you sure you searched well? You can find everything on our friendly forum:)

Look here.

Kind regards

5 Likes

This is easily done with mycadtools.

4 Likes

Thank you droger,
I'm trying this lunchtime, not always easy to do a search, it all depends on the terms to look for, easier when you yourself participated in the post!
I should have searched for "macro+drogue"
;-D  A+

 

 

1 Like

Thank you all,
After hacking the gdm code, it works! All that's left to do is "clean" my code and it's good.

Hi, I think it's possible to open the room without displaying it, I searched but found nothing convincing on the forum.
Thank you for pointing me in the right direction.

Hello

Here's a small example:

Option Explicit

Sub main()

    Dim swApp As SldWorks.SldWorks
    Dim swModel As SldWorks.ModelDoc2
    Dim swDrawModel As SldWorks.ModelDoc2
    Dim swDraw As SldWorks.DrawingDoc
    Dim swView As SldWorks.View
    Dim swModelDocExt As ModelDocExtension
    Dim strRefModelPath As String
    Dim configname As String
    Dim bRet As Boolean
    Dim nErrors As Long
    Dim nWarnings As Long
    Dim swCustProp As CustomPropertyManager
    Dim val As String
    Dim valout As String

    Set swApp = CreateObject("SldWorks.Application")
    Set swModel = swApp.ActiveDoc
    Set swDraw = swModel
    Set swView = swDraw.GetFirstView

    While Not swView Is Nothing
        strRefModelPath = swView.GetReferencedModelName
        configname = swView.ReferencedConfiguration
        Set swDrawModel = swApp.OpenDoc6(strRefModelPath, swDocPART, swOpenDocOptions_Silent, "", nErrors, nWarnings)
        If Not swDrawModel Is Nothing Then
            Set swModelDocExt = swDrawModel.Extension
            Set swCustProp = swModelDocExt.CustomPropertyManager(configname)
            bRet = swCustProp.Get4("TEST", False, val, valout)
        
            Debug.Print "valeur évaluée : " & valout
        End If
        Set swView = swView.GetNextView
    Wend

End Sub

Kind regards

2 Likes

Good evening
Thank you very much drogue, I just reworked everything and it works perfectly without opening the 3d model.
On the other hand, I don't see the point of looping on the configurations because it takes the "Index" => property (valout) of the last config found. My goal is to compare the index of the 3d with that of the MeP before adding it to the file name and saving as a pdf.
It could be useful if the index was mistakenly different between 2 configs, which is not the case in our 3d management. unlike "old" MeP which are not always at the last 3d index.
Yours sincerely.

 

 

This is just an example that I gave you, without really knowing your real need... Example on which I don't loop on the configs but on the drawing views which is not necessarily useful either ... In the same way that this example only works as it is if the reference 3D model is a part, otherwise there are some modifications to be made...

In short, just an example to see how to solve the problem stated in your question.

Kind regards

2 Likes

Hello, Indeed I didn't give you any indication of my need! sorry I got lost... And you answered the problem posed in the question, as usual I will say.

For assemblies I guess you have to change swPART by swASSEMBLY?
I'm doing some tests and will surely come back for valuable advice ;-)
Enjoy WE

 

 

 

1 Like

Hello, After a few positive tests, I am joining the macro, I am counting on you to improve it because I think it can be simplified but as it works I don't dare to touch it anymore...


save-pdf-dxf.swp

Good evening

I'm coming a little after the battle, but if the clue is in a linked note in the cartouche, it was possible to rely on this note rather than interrogating the 3D.

This simplifies the operation and does not depend on the type of file being linked.

Good evening Cyril, well no that's the pb, we have many shots whose index has been 'forced', while the 3ds are well revised and indexed, that's why I put the difference in a message, so we put the right index back in the MeP, It's twisted of course but we deal with it.

1 Like

Hello fifounet44,

Overall it does the job, it still lacks the management of possible errors but it's recurrent on all the macros that we can see ...

Think about closing the subject...

Kind regards

3 Likes