10 Replies Latest reply on Nov 7, 2016 1:49 PM by Tang Tang

    SWDM-api question seek help

    Tang Tang

      At first,thank you fou your help.I'm a Chinese people,  I only can speak Chinglish.Sorry for my poor English. Please do me a favor. Thank you!

      I‘m editing a SWDM-API,it's work on office-excel.  my editing tools is VBA.

      the macro code as follows.It's usd for open a drawing ,then open a model has being used by  the drawing.

      Now I can get the model's  ActiveConfiguration ,but My demand is open the model with the  Configuration being used by the drawing.

      How should I do? Can anybody help me?

      thank you very much.

       

      Sub GetRefdModelPrp()

          Dim swDM As SwDMApplication

          Dim swDoc As SwDMDocument14

          Dim swClassfac As SwDMClassFactory

          Dim mOpenErrors As SwDmDocumentOpenError

          Dim swCfgMgr As SwDMConfigurationMgr

          Dim swModel As SwDMDocument12

          Dim dmSearchOpt As SwDMSearchOption

          Dim RefModelNameArr_  As Variant

          Dim vRefModelName_  As String

          Dim vActiveCfg_ As SwDMConfiguration12

         Const SWDMLicenseKey = "SWDMLicenseKey"

       

        FilePath_ = Cells(3, 1)

          FileName_ = Cells(3, 2)

          Set swClassfac = CreateObject("SwDocumentMgr.SwDMClassFactory")

          Set swDM = swClassfac.GetApplication(SWDMLicenseKey)

          Set swDoc = swDM.GetDocument(FilePath_ & FileName_, 3, False, mOpenErrors) 'Open drawing

          RefModelNameArr_ = swDoc.GetAllExternalReferences(dmSearchOpt) 'Get all Referenced model

          vRefModelName_ = RefModelNameArr_(LBound(RefModelNameArr_)) 'Get first Referenced model

          If "PRT" = UCase(Right(vRefModelName_, 3)) Then

              ModelType = 1

          Else

              ModelType = 2

          End If

       

          Set swModel = swDM.GetDocument(vRefModelName_, ModelType, False, mOpenErrors) 'Open Referenced model

          Set swCfgMgr = swModel.ConfigurationManager

          ActiveCfgName_ = swCfgMgr.GetActiveConfigurationName

          Set vActiveCfg_ = swCfgMgr.GetConfigurationByName(ActiveCfgName_)    '??? how can I get the  Configuration name being used by the drawing Referenced ?

                                                                                                                                      'or how can I  then get ReferencedConfiguration after I get the model?

        

          swModel.CloseDoc

      End Su