iLogic Try, Catch, Error... ?

iLogic Try, Catch, Error... ?

Anonymous
Not applicable
1,718 Views
2 Replies
Message 1 of 3

iLogic Try, Catch, Error... ?

Anonymous
Not applicable

Basically, I'm trying to assign an appearance to a face.

 

1. Try: Assign appearance to face

 

2. Catch (if the appearance isn't in the current doc)

Try to bring it in from a library

 

3. ????? (what if the appearance isn't found in a library) <<< Is this going to be another "Catch" line????

Show message "Can't be found"

 

Or perhaps, I need to us "On Error"?

 

Thanks.

0 Likes
1,719 Views
2 Replies
Replies (2)
Message 2 of 3

tdant
Collaborator
Collaborator

You can use multiple Catches in a Try statement, using either an error type or When statement to qualify the Catches.

Try [GetApperance]
Catch ex1 When IsError([GetAppearance])
     ' error handler for ex1
Catch ex2
     ' error handler for ex2
End Try
0 Likes
Message 3 of 3

chandra.shekar.g
Autodesk Support
Autodesk Support

@Anonymous,

 

Try below iLogic code to assign a color to face.

 

 Dim oPartDoc As PartDocument 
	oPartDoc = ThisApplication.ActiveDocument 
    
	Dim oFace As Face 
	oFace = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter, "Select a face")
	
	'define the appearance library
	Dim oLib As AssetLibrary
	oLib = ThisApplication.AssetLibraries("Autodesk Appearance Library")

	'make sure colors are in assembly doc
	Dim libAsset As Asset
	libAsset = oLib.AppearanceAssets.Item("Steel") 

	Dim localAsset As Asset 
	Try  
		localAsset = oPartDoc.Assets.Item("Steel") 
	Catch 
		localAsset = libAsset.CopyTo(oPartDoc)
	End Try 
	
	oFace.Appearance = localAsset

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes