iLogic Rule - Not Working

iLogic Rule - Not Working

Anonymous
Not applicable
863 Views
3 Replies
Message 1 of 4

iLogic Rule - Not Working

Anonymous
Not applicable

I have this iLogic rule where it will pick up the file name and a custom iProperty per sheet in a drawing pack. However, it will not work on my PC, the code is correct and i think its something within the application on my pc, please help! 

 

Code 

 

SyntaxEditor Code Snippet

Sub Main()
'Purpose: Push file name to sheet name'21-Sept-16

Dim oDoc As Document = ThisApplication.ActiveDocument
Dim oSheet As Sheet
Dim oDrawingView As DrawingView

'Iterate through sheets
For Each oSheet In oDoc.Sheets
    'Grab the first drawing view on the sheet
    oDrawingView = oSheet.DrawingViews(1)

    'Grab the model of the first drawing view
    oModel = oDrawingView.ReferencedDocumentDescriptor.ReferencedDocument 

    'Grab the custom iproperty of the first drawing view model
    oModel1 = oDrawingView.ReferencedDocumentDescriptor.ReferencedDocument.DisplayName
    o_iProp = iProperties.Value(oModel1, "Custom", "RevisionUK")  

    'set sheet name to filename and custom iprop from model
    oSheet.Name = System.IO.Path.GetFileNameWithoutExtension(oModel.FullFileName)& " - " & o_iProp


Next 

End Sub

 

 

Error Message

 

Object reference not set to an instance of an object

 

 

Error Message

 

Image.png

 

 

0 Likes
Accepted solutions (1)
864 Views
3 Replies
Replies (3)
Message 2 of 4

Martin-Winkler-Consulting
Advisor
Advisor

Hi @Anonymous

 

try this code:

 

Sub Main()
'Purpose: Push file name to sheet name'21-Sept-16

Dim oDoc As Document = ThisApplication.ActiveDocument
Dim oSheet As Sheet
Dim oDrawingView As DrawingView

'Iterate through sheets
For Each oSheet In oDoc.Sheets
    'Grab the first drawing view on the sheet
    oDrawingView = oSheet.DrawingViews(1)
	
	'Grab the model of the first drawing view
    oModel = oDrawingView.ReferencedDocumentDescriptor.ReferencedDocument 

	'Grab the custom iproperty of the first drawing view model
    oModel1 = oDrawingView.ReferencedDocumentDescriptor.ReferencedDocument.DisplayName
    o_iProp = iProperties.Value(oModel1, "Custom", "RevisionUK")  

    'set sheet name to filename and custom iprop from model
    oSheet.Name = FileNameFromPathWithoutExt(oModel.FullFileName)& " - " & o_iProp


Next 

End Sub

Function FileNameFromPathWithoutExt(strFullPath As String) As String
    FileNameFromPathExt = Right(strFullPath, Len(strFullPath) - InStrRev(strFullPath, "\"))
    FileNameFromPathExt = Left(FileNameFromPathExt, InStrRev(FileNameFromPathExt, ".") - 1)
End Function

Martin Winkler
CAD Developer
Did you find this post helpful? Feel free to like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


EESignature

0 Likes
Message 3 of 4

MechMachineMan
Advisor
Advisor
Accepted solution

You can also try tweaking your windows settings to SHOW file extensions for unknown file types.


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
Message 4 of 4

Anonymous
Not applicable

This didn't solve the issue, same error code

0 Likes