ilogic Question

ilogic Question

millenat1094
Explorer Explorer
401 Views
6 Replies
Message 1 of 7

ilogic Question

millenat1094
Explorer
Explorer

Hello, I found this code on another form that rotates your appearance, like if you have a wood grain and want the direction to be different. Unfortunately, it keeps giving me the error "Object reference not set to an instance of an object."

I am not skilled enough to know what's going wrong here. Any help would be greatly appreciated 🙂 thanks!

 

 

 

Dim oDoc As PartDocument = ThisDoc.Document

Dim oAppearance As Asset = oDoc.ActiveAppearance

Dim oValue As AssetValue

For Each Value In oAppearance

    If oValue.ValueType = AssetValueTypeEnum.kAssetValueTextureType Then

        Dim oTextureAssetValue As TextureAssetValue = oValue

        Dim oTexture As AssetTexture = oTextureAssetValue.Value

        If oTexture.Item("unifiedbitmap_png").Value <> ""Then

              oTexture.Item("texture_WAngle").Value = TextureAngle

		  End If

	  End If

Next
0 Likes
Accepted solutions (1)
402 Views
6 Replies
Replies (6)
Message 2 of 7

PolemEngineering
Advocate
Advocate

Changing

 

 

For Each Value in oAppearance

 

 

in

 

 

For Each oValue In oAppearance

 

 

solves that error. What the rest of the code does is not entirely clear to me. 

Code line 4 and 5 can also be combined like:

For Each oValue As AssetValue In oAppearance

 

René van der Starre

Message 3 of 7

millenat1094
Explorer
Explorer

Thanks for your help. Unfortunately, the whole thing didn't work. I'm trying to get my textures to rotate with ilogic and can't seem to figure it out

0 Likes
Message 4 of 7

WCrihfield
Mentor
Mentor

Hi @millenat1094.  That's a tough situation...and trying to fix it by code probably just multiplies the difficulty/complexity.  Digging into all of the different types and levels of AssetValue objects associated with an Asset object can be pretty challenging.  It is usually best to use an iLogic rule (or similar) to 'read' through all that data first, just to see what all is there, and what types of values they may have.  I have attached a text file containing some pretty complex iLogic code you can use in an iLogic rule (by itself) for inspecting all that data.  Then, once you are more familiar with all that, try to access the specific properties you want.  We can still do more manually, though the user interface dialogs, than we can by code in that area.

 

On a side note, there are a couple other curiosities I have come across, but have not yet explored into that much, but you may be able to look into if you are feeling inquisitive.

SurfaceBody.GetAppearanceTextureMappingData 

SurfaceBody.SetAppearanceTextureMappingData 

Face.GetTextureScale (I did not find a 'SetTextureScale' method)

Face.TextureMaps 

TextureMaps 

TextureMap 

 

 

 

 

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 5 of 7

millenat1094
Explorer
Explorer

OKay, thank you for that. Altho i ran the rule and it did nothing. Is it putting that info into a text file? I tried to read though it but I am not very good at that yet

0 Likes
Message 6 of 7

WCrihfield
Mentor
Mentor
Accepted solution

No, it is supposed to write all that data into the iLogic Log window.  However, you must have had that 'iLogic Log' tab available before starting the rule, otherwise it will not be able to capture it.  To make sure that tab is visible, go to the View tab, then on the Windows panel, click the drop-down arrow by the 'User Interface' tool.  Then make sure the checkbox is checked next to the 'iLogic Log' option.

WCrihfield_0-1732647306763.png

That should show a new tab next to your current 'iLogic' tab, and next to your 'Model' tab.  As long as that tab is visible (not necessarily active), then you run that rule, then you go to that tab and click on it (activate it), then you should see that a bunch of data has been written into that window area.  That window area is usually used for debugging and code related feedback information, but is also very convenient for writing other temporary data to, instead of writing it out to a separate text file.

Although, that is likely a lot of data, so writing it out to a text file would have probably been a better idea in this case.

 

Edit:  You may also need to make sure that your 'Log Level' is not set too low.  That setting can be found in 2 different places.  One is on the Tools tab, expand the Options panel down, then click on the iLogic Configuration tool.  In that small dialog, I usually keep my 'Logging' level set to Trace, which is the highest level (most detail), but keep the 'Detailed Trace' setting turned off (checkbox unchecked).  That Detailed Trace will write something into that window every single time a rule starts and finishes, which is usually not necessary, and can fill up that screen with relatively useless information.  The other place you can see and set those same settings is at the bottom of your iLogic rule editor dialog, when you are editing an iLogic rule.

WCrihfield_1-1732647759539.png

 

 

 

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 7 of 7

millenat1094
Explorer
Explorer

Oh my, I had no idea that box even existed. That will help a lot! thank you for your help. I really appreciate it!

0 Likes