iLogic External Rule Cycle Through Open Documents

iLogic External Rule Cycle Through Open Documents

ben.coxL97MN
Explorer Explorer
775 Views
5 Replies
Message 1 of 6

iLogic External Rule Cycle Through Open Documents

ben.coxL97MN
Explorer
Explorer

I'm trying to write an external rule that will cycle through all open drawings and fill in the "Eng. Approved By:" and "Eng. Approved Date:" item in the iproperties. The code I have will update the first drawing, then will cycle through all the open drawings, but will only update the drawings that was initially active. Can anyone see what I'm missing?

 

Dim oDoc As Document = ThisApplication.ActiveDocument

Dim ApprovedBy As String = InputBox("Enter Approving Engineer's Intials", "Engineer Approval", "Initials")

For Each oDoc In ThisApplication.Documents.VisibleDocuments
	
	If oDoc.DocumentType = kDrawingDocumentObject Then

		oDoc.Activate

		iProperties.Value("Status", "Engr Approved By") = ApprovedBy
		iProperties.Value("Status", "Engr Date Approved") = Now
	
	End If
Next
	
MessageBox.Show("All Open Drawings Approved.", "ApproveDwgs")


Thank you all so much!
0 Likes
Accepted solutions (1)
776 Views
5 Replies
Replies (5)
Message 2 of 6

A.Acheson
Mentor
Mentor

The issue here is the iproperty snippet is only acting in the document the rule is run from. You can target  each document by getting the document name with extension. Here is the Syntax on targeting the document.

The system IO Documentation here or shorten to IO in the ilogic editor. You may have seen this in other forum posts. 

 

 

Dim oDoc As Document = ThisApplication.ActiveDocument

Dim ApprovedBy As String = InputBox("Enter Approving Engineer's Intials", "Engineer Approval", "Initials")

For Each oDoc In ThisApplication.Documents.VisibleDocuments
	
	If oDoc.DocumentType = kDrawingDocumentObject Then

		oDoc.Activate
Dim oDocName As String = IO.Path.GetFileName(oDoc.FullFileName) iProperties.Value(oDocName,"Status", "Engr Approved By") = ApprovedBy iProperties.Value(oDocName,"Status", "Engr Date Approved") = Now End If Next MessageBox.Show("All Open Drawings Approved.", "ApproveDwgs")


Thank you all so much!
 
If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 3 of 6

A.Acheson
Mentor
Mentor
Accepted solution

I am not sure why but the iproperty snippet for targeting other drawings does not work.  What does work is accessing via the property sets method. 

Dim ApprovedBy As String = InputBox("Enter Approving Engineer's Intials", "Engineer Approval", "Initials")
If ApprovedBy = Nothing Then Return
For Each oDoc In ThisApplication.Documents.VisibleDocuments
	
	Dim oDrawDoc As DrawingDocument
	If oDoc.DocumentType = DocumentTypeEnum.kDrawingDocumentObject Then
		oDrawDoc = oDoc
		oDrawDoc.PropertySets("Design Tracking Properties")("Engr Approved By").Value = ApprovedBy
		oDrawDoc.PropertySets("Design Tracking Properties")("Engr Date Approved").Value = Now
	End If
Next
MessageBox.Show("All Open Drawings Approved.", "ApproveDwgs")

Here is a rule to give you a list of the property sets of the document in the ilogic logger. You can use this to construct the iproperty access as above.

  Dim doc As Document
 doc = ThisApplication.ActiveDocument
  
  Dim ps As PropertySet
  For Each ps In doc.PropertySets
   Logger.Info( ps.Name + " / " + ps.InternalName)

    Dim p As [Property]
    For Each p In ps
      Logger.Info( "  " + p.Name + " /" + Str(p.PropId))
    Next
  Next
  

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 4 of 6

WCrihfield
Mentor
Mentor

Hi @A.Acheson.  Just a quick note on why the iProperties iLogic snippet wouldn't work...  When attempting to work with the iProperties in another document, it is limited to the documents available within the AllReferencedDocuments of the 'local' (document the rule is saved within) or 'active' document.  I picked up that little nugget from Mike Deck this past year (as well as a bit more testing of my own), after I went on a mini-rant about the confusion with this snippet over the years, with how undocumented its input requirements are, its seemingly unreliable/unpredictable behavior, and the undocumented system of determining which document it will act upon by default in different situations.  At the time, I too was trying to use it to act upon a 'parallel' document (another visibly open document, other than the one I'm currently working with), rather than a document being referenced by the 'local' or 'active' document.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 5 of 6

ben.coxL97MN
Explorer
Explorer
That worked perfect. Thank you so much. I tried to use the property sets method, but it looks like I overcomplicated what I was trying to do, and couldn't get it to work right.
0 Likes
Message 6 of 6

manuel.cervantesKANB9
Explorer
Explorer

hi 

for other properties like Author, please see the following information 

 

Inventor Summary Information
Property NameType
AuthorString
CommentsString
KeywordsString
Last Saved ByString
ThumbnailIPictureDisp
Revision NumberString
SubjectString
TitleString
 
Inventor Document Summary Information
Property NameType
CategoryString
CompanyString
ManagerString
 
Design Tracking Properties
Property NameType
AuthorityString
Catalog Web LinkString
CategoriesString
Checked ByString
CostCurrency
Cost CenterString
Creation TimeDate
Date CheckedDate
Defer UpdatesBoolean
DescriptionString
Design StatusLong
DesignerString
Document SubTypeString
Document SubType NameString
EngineerString
Engr Approved ByString
Engr Date ApprovedDate
External Property Revision IdString
LanguageString
ManufacturerString
MaterialString
Mfg Approved ByString
Mfg Date ApprovedDate
Parameterized TemplateBoolean
Part IconIPictureDisp
Part NumberString
Part Property Revision IdString
ProjectString
Proxy Refresh DateDate
Size DesignationString
StandardString
Standard RevisionString
Standards OrganizationString
Stock NumberString
Template RowString
User StatusString
VendorString
Weld MaterialString

 

thanks

0 Likes