- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Ok, so if the code works good up until that point, you need to very careful examine everything that happens after.
In this case:
If MatchFound = True Then
oAsset = oAssyDoc.Assets.Item("Smooth - Red")
End If
oOcc.Appearance = oAsset
Next
What we set is that oASSET is assigned a value inside an if loop. If TRUE, the oASSET value gets assigned, if FALSE, the oAsset value isn't assigned. Look back through all of the code before this, and we see there is no default value assigned to the oASSET OBJECT.
If we look past the IF Statement, we see that the program is trying to assign the oASSET to an object, so of course it will fail.
There's really only 2 ways to fix it: ensure the oAsset variable DOES have a value when we try to assign it, or don't assign it.
We could add an if statement before the
oOcc.Appearance = oAsset
line to ensure that the line is only run if NOT (oAsset is Nothing)... but that would be redundant, since we can just move the line inside of the if loop that assigns the oAsset value.
--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.
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