AnsweredAssumed Answered

Edit Custom Property of a Drawing without opening it

Question asked by Damien Mallard on Oct 22, 2015
Latest reply on Nov 11, 2015 by Ed Cyganik

Hi,

 

I See this thread

How to get the file custom property from a drawing doc without SW openning it ?

It is interesting but what i want is to edit with my app developed in VB.Net to Edit some Custom Property without opening it in SW to save time on Execution At this Time I Work with this

Function EditDrawingProperties(DrawingToEdit As String)
    Dim swDocSpecification As SldWorks.DocumentSpecification = swApp.GetOpenDocSpec(DrawingToEdit)
    swDocSpecification.Silent = True : swDocSpecification.ReadOnly = False : swApp.OpenDoc7(swDocSpecification)
    Dim Drawing As DrawingDoc = swApp.ActiveDoc
    Dim swModel As ModelDoc2 = swApp.ActiveDoc
    Dim swModelDocExt As ModelDocExtension = swModel.Extension
    Dim swCustProp As CustomPropertyManager = swModelDocExt.CustomPropertyManager("")
    swCustProp.Add3("LBM_DWG", 30, Regex.Match(DrawingToEdit, "N°([0-9]+)-0.SLDDRW", RegexOptions.IgnoreCase).Groups(1).Value, 2)
    swCustProp.Add3("LBM_REV", 30, 0, 2)
    swCustProp.Add3("LBM_REV1", 30, 0, 2)
    swCustProp.Add3("LBM_DATE1", 30, Dateddmmyy, 2)
    swCustProp.Add3("LBM_MEMO1", 30, "First Issue", 2)
    swCustProp.Add3("LBM_ISSUED1", 30, User(), 2)
    swCustProp.Add3("LBM_PROJECT", 30, DrawingToEdit.Split(New Char() {"\"c})(5), 2)
    Drawing.ForceRebuild() 'Reconstruction
    Dim fileerror, filewarning As Integer
    swModel.Save3(SwConst.swSaveAsOptions_e.swSaveAsOptions_Silent, fileerror, filewarning)
    swApp.CloseDoc(DrawingToEdit)
    Return Nothing
End Function

But this take many times when i have 20 drawing and more and each one take a minute to open.

 

If anyone have an idea

Outcomes