Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hey guys I cant figure out why my imbedded rule isn't outputting any files.
The expected workflow is:
- run external rule "FO - Export STP From Drawing Rev Date" from IDW
- the rule then checks if the IDW is a IPT or IAM drawing
- sets the path to the appropriate model
- opens the model
- run 2nd external rule "FO - STP Rev Date" from within that model to export the STP
- closes the model
When running the 2nd rule straight from the model it works just fine but from the drawing I'm not getting any errors and the model opens and closes but no file is created so I think that opening the model essentially does nothing.
Does anyone know how to make this work? Or even better is there a way to run the second rule like it is run from within the model without opening the model in the first place? rule 1 "FO - Export STP From Drawing Rev Date" below
doc = ThisDoc.ModelDocument Dim oPartPath As String If doc.DocumentType = kPartDocumentObject Then oPartPath = ThisDoc.PathAndFileName(False) & ".ipt" Else If doc.DocumentType = kAssemblyDocumentObject Then oPartPath = ThisDoc.PathAndFileName(False) & ".iam" End If ' Set a reference to the target part oPart = ThisApplication.Documents.ItemByName(oPartPath) ' Open the target part 'ThisApplication.Documents.Open(oPartPath) ThisDoc.Launch(oPartPath) ' Save a copy of oPart as a step file iLogicVb.RunExternalRule("FO - STP Rev Date") ' Close oPart oPart.Close
rule 2 "FO - STP Rev Date" Below
'Get Current date Dim Time As DateTime = DateTime.Now Dim Format As String = "yyMMdd" 'Get filename without extension Dim oFileName As String oFileName = ThisDoc.FileName(False) 'set custom naming convention for output file Dim sPartNumb As String = iProperties.Value("Project", "Part Number") & "_" & iProperties.Value("Project", "Revision Number") & "_" & Time.ToString(Format) 'Export parameters If TypeOf ThisDoc.Document Is PartDocument Or TypeOf ThisDoc.Document Is AssemblyDocument Then Dim oDoc As Document = ThisDoc.Document Dim oSTEPTranslator As TranslatorAddIn = ThisApplication.ApplicationAddIns.ItemById("{90AF7F40-0C01-11D5-8E83-0010B541CD80}") Dim oContext As TranslationContext = ThisApplication.TransientObjects.CreateTranslationContext Dim oOptions As NameValueMap = ThisApplication.TransientObjects.CreateNameValueMap oPath = ThisDoc.Path If oSTEPTranslator.HasSaveCopyAsOptions(oDoc, oContext, oOptions) Then ' Set application protocol. ' 2 = AP 203 - Configuration Controlled Design ' 3 = AP 214 - Automotive Design oOptions.Value("ApplicationProtocolType") = 3 ' Other options... 'oOptions.Value("Author") = "" 'oOptions.Value("Authorization") = "" 'oOptions.Value("Description") = "" 'oOptions.Value("Organization") = "" oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism Dim oData As DataMedium = ThisApplication.TransientObjects.CreateDataMedium 'get Output target folder path oFolder = oPath & "\" & oFileName & "\" 'Check for the Outputs folder and create it if it does not exist If Not System.IO.Directory.Exists(oFolder) Then System.IO.Directory.CreateDirectory(oFolder) End If oData.FileName = oFolder & sPartNumb & ".stp" oSTEPTranslator.SaveCopyAs(oDoc, oContext, oOptions, oData) End If ' End If Else MessageBox.Show("Message", "Title") end if
Solved! Go to Solution.