- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
hello
I've used copy & paste to move an iLogic rule which works locally to overwrite an external rule & now see this error:
How do I expose the variable?
Regards
Andrew
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Variables declared within block statements like If/Then, Try/Catch, For/Next, etc. have "block scope" and are only available within the code block in which they're declared. So if you try to use them outside the block, you'll get a compile error.
To make the variable available to your entire procedure, declare it outside the Try/Catch block, and then just set its value within the Catch block, like this:
Dim oVariable As VariableType
Try
'...
Catch
oVariable = ...
End Try
I'm surprised this worked at all in your local rule. It's difficult to determine why without seeing more of your code. But regardless, you should only declare a variable within a block if it's ONLY going to be used in that block.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
SyntaxEditor Code Snippet
Dim BE_PC as String Dim DisciplineCode As String
I added the lines above at the start of the code but still see, 'BE_PC' hides & 'DisciplineCode' hides.
Thanks for looking.
Andrew
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I watch an AU tutorial which suggested bug fixing using visual studio:
i'll need to watch it again!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
So did you get it working? If not, can you post your full code? (as text, not as a picture)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Actually, variable name (like BE_PC) and parameter name in drawing document are same. This is actual cause for errors.
Usually, all parameters in documents are defined with same variable name. For Example, If "BE_PC" parameter is defined in a document, "BE_PC" variable name is used in iLogic and can not be used again to another variable name.
In the attached rule, I can see all variable names are same as parameter names.
Thanks and regards,
CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello
I stripped the code back & the error message highlights a different line to what causes the problem:
SyntaxEditor Code Snippet
Dim oDrawDoc As DrawingDocument = ThisApplication.ActiveDocument Dim oDrawParams As UserParameters = oDrawDoc.Parameters.UserParameters 'oMyParameter = ThisApplication.ActiveDocument.ComponentDefinition.Parameters.UserParameters Try 'Change value of param Parameter("BE_PC") = Parameter("BE_PC") Catch 'Create Param as it doesn't exist Dim BE_PC As UserParameter = oDrawParams.AddByValue("BE_PC" , "BE", UnitsTypeEnum.kTextUnits) End Try
the above works, it's adding the code below which causes the error:
SyntaxEditor Code Snippet
MultiValue.SetList("BE_PC", "BE", "PC") BE_PC = "BE"
So far:
Open a drawing, check if the required parameter is there - working
if it's not there create it - working
make the parameter multivalue - failing
the error is caused by lines 14 & 15 - not line 11:
Thanks again
Andrew
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
It would be better to test the error with document. So, please provide sample document to test the situation (Make sure that files are non confidential).
Thanks and regards,
CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Still I strongly believe that error is due to line 12. Below iLogic code does not throw error. Just changed variable name for userparameter from BE_PC to BE_PC_1.
BE_PC = "BE"' deleted parameter
Dim oDrawDoc As DrawingDocument = ThisApplication.ActiveDocument
Dim oDrawParams As UserParameters = oDrawDoc.Parameters.UserParameters
'oMyParameter = ThisApplication.ActiveDocument.ComponentDefinition.Parameters.UserParameters
Try
'Change value of param
Parameter("BE_PC") = Parameter("BE_PC")
Catch
'Create Param as it doesn't exist
Dim BE_PC_1 As UserParameter = oDrawParams.AddByValue("BE_PC" , "BE", UnitsTypeEnum.kTextUnits)
End Try
MultiValue.SetList("BE_PC", "BE", "PC")
BE_PC = "BE"
Thanks and regards,
CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report