Would it be possible to to run rule and have table in that sheet to be selected?
I have rule that place table in right upper corner. Sometimes it is not nice loking since description change. So i pick table and then run rule to fix columns to looks nice. I would like to make one rule to run all rules and table to be every time good. Can somebody help ?
Thanks
Solved! Go to Solution.
Would it be possible to to run rule and have table in that sheet to be selected?
I have rule that place table in right upper corner. Sometimes it is not nice loking since description change. So i pick table and then run rule to fix columns to looks nice. I would like to make one rule to run all rules and table to be every time good. Can somebody help ?
Thanks
Solved! Go to Solution.
Solved by GosponZ. Go to Solution.
Solved by WCrihfield. Go to Solution.
Hi @GosponZ. Just to clarify...do you want an iLogic rule example that includes utilizing the 'Pick' function, which would allow the user to manually select the table with their mouse, after the rule starts? Or do you want the rule to automatically select the first CustomTable it finds on the 'active' sheet, without needing any user interaction? If you want the rule to select it, then what should the rule do with it once it gets selected?
Below is an example using the 'Pick' function, but I am not sure if this is what you wanted.
Dim sPrompt As String = "Select a Table on the active sheet of a drawing."
Dim oPickedCTable As CustomTable = Nothing
'allow user to manually choose a table using their mouse
oPickedCTable = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingCustomTableFilter, sPrompt)
'make sure something was selected...if not, then exit this rule
If oPickedCTable Is Nothing Then Return
'this actually adds to the document's selected items
ThisDoc.Document.SelectSet.Select(oPickedCTable)
Edit: Below is an example that just selects the first CustomTable it finds on the active sheet. If there are none, it will let you know, then end the rule. If there are multiple, and you do not want the first one, then how should the code identify the one you want to be working with?
Sub Main
Dim oDDoc As DrawingDocument = TryCast(ThisDoc.Document, Inventor.DrawingDocument)
If oDDoc Is Nothing Then Return
Dim oASheet As Inventor.Sheet = oDDoc.ActiveSheet
Dim oCTables As CustomTables = oASheet.CustomTables
If oCTables.Count = 0 Then
MsgBox("There are no CustomTables on the active sheet of this drawing!", vbCritical, "iLogic")
Return
End If
Dim oCTable As CustomTable = oCTables.Item(1)
oDDoc.SelectSet.Select(oCTable)
End Sub
Wesley Crihfield
(Not an Autodesk Employee)
Hi @GosponZ. Just to clarify...do you want an iLogic rule example that includes utilizing the 'Pick' function, which would allow the user to manually select the table with their mouse, after the rule starts? Or do you want the rule to automatically select the first CustomTable it finds on the 'active' sheet, without needing any user interaction? If you want the rule to select it, then what should the rule do with it once it gets selected?
Below is an example using the 'Pick' function, but I am not sure if this is what you wanted.
Dim sPrompt As String = "Select a Table on the active sheet of a drawing."
Dim oPickedCTable As CustomTable = Nothing
'allow user to manually choose a table using their mouse
oPickedCTable = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingCustomTableFilter, sPrompt)
'make sure something was selected...if not, then exit this rule
If oPickedCTable Is Nothing Then Return
'this actually adds to the document's selected items
ThisDoc.Document.SelectSet.Select(oPickedCTable)
Edit: Below is an example that just selects the first CustomTable it finds on the active sheet. If there are none, it will let you know, then end the rule. If there are multiple, and you do not want the first one, then how should the code identify the one you want to be working with?
Sub Main
Dim oDDoc As DrawingDocument = TryCast(ThisDoc.Document, Inventor.DrawingDocument)
If oDDoc Is Nothing Then Return
Dim oASheet As Inventor.Sheet = oDDoc.ActiveSheet
Dim oCTables As CustomTables = oASheet.CustomTables
If oCTables.Count = 0 Then
MsgBox("There are no CustomTables on the active sheet of this drawing!", vbCritical, "iLogic")
Return
End If
Dim oCTable As CustomTable = oCTables.Item(1)
oDDoc.SelectSet.Select(oCTable)
End Sub
Wesley Crihfield
(Not an Autodesk Employee)
Wesley,
as always thank you for fast respond. First code is not doing. It will not select. Second it just go to msg that is no custome table. It is always only one table in sheet that is material part number and qty
Idea is, if possible, to run 3 rules in one rule
First one to get table on desired place , second rule to promt to select table and third one to adjust table.
Wesley,
as always thank you for fast respond. First code is not doing. It will not select. Second it just go to msg that is no custome table. It is always only one table in sheet that is material part number and qty
Idea is, if possible, to run 3 rules in one rule
First one to get table on desired place , second rule to promt to select table and third one to adjust table.
Hi @GosponZ. I guess I need to know what type of table it is then. How is the table being created? Is it a revision table, a parts list, a hole table, or is it a custom sketched type of table, such as a SketchedSymbol. If I do not know what type of object it is, it is difficult to write super specific code to find it and do something with it.
As for combining multiple rules...perhaps you could post your current rules here. You can attach them as individual text files, or you can paste their contents within code windows in a forum response (using the </> tool). If it is possible, and I (we) have time, we'll see what we can do for you. Plus, seeing your current code may clue me (us) in on what type of object it is, so we can find it easier.
Wesley Crihfield
(Not an Autodesk Employee)
Hi @GosponZ. I guess I need to know what type of table it is then. How is the table being created? Is it a revision table, a parts list, a hole table, or is it a custom sketched type of table, such as a SketchedSymbol. If I do not know what type of object it is, it is difficult to write super specific code to find it and do something with it.
As for combining multiple rules...perhaps you could post your current rules here. You can attach them as individual text files, or you can paste their contents within code windows in a forum response (using the </> tool). If it is possible, and I (we) have time, we'll see what we can do for you. Plus, seeing your current code may clue me (us) in on what type of object it is, so we can find it easier.
Wesley Crihfield
(Not an Autodesk Employee)
Ok make sense. Table is just part list table designated forpart description , part number width and length, and qty.
This is rule that will place table in drawing. In parameters there is multi value different parts lists.
auto fit columns it has pick funtion but have to pick table first and then run rule.
Ok make sense. Table is just part list table designated forpart description , part number width and length, and qty.
This is rule that will place table in drawing. In parameters there is multi value different parts lists.
auto fit columns it has pick funtion but have to pick table first and then run rule.
Hi @GosponZ. I'm not sure if this is what you wanted, but this is what your getting, because I think I'm done with it, plus I'm about to leave for the weekend. Have a great weekend. 😅
(See attached text file.)
Wesley Crihfield
(Not an Autodesk Employee)
Hi @GosponZ. I'm not sure if this is what you wanted, but this is what your getting, because I think I'm done with it, plus I'm about to leave for the weekend. Have a great weekend. 😅
(See attached text file.)
Wesley Crihfield
(Not an Autodesk Employee)
HI Wesley,
thank you for your help. Rule is working but ...
First when runing rule it is not fit but run one more time get perfect. So need run rule twice.
Second if run rule and choose laser can't replace with other even if delete table. It is manageable but if you can take a look one more time please.
HI Wesley,
thank you for your help. Rule is working but ...
First when runing rule it is not fit but run one more time get perfect. So need run rule twice.
Second if run rule and choose laser can't replace with other even if delete table. It is manageable but if you can take a look one more time please.
Hi @GosponZ. I think I see one problem in the code I attached above. I originally did not include the whole 'AddPartsList' Function in there, so down at Lines 21 through Line 25, I was originally just going to show a message, then exit the rule, when no PartsList was either pre-selected, found, or Picked. Then I added Line 22 later, which is the line of code that runs that custom Function. When I made that change, I commented out Line 23 (where it shows the message), but did not comment out Line 24 (Return), when I should have. So, in cases where no existing PartsList was pre-selected, found, or picked, it is calling that 'add' method, but then immediately exiting the rule, before it gets to the line of code that runs the Function to auto fit the column widths.
If this is the only problem, then you can just delete Lines 23 & 24 (the MessageBox.Show & the Return), to solve this problem.
However, I should have also included one or two lines of code at the end of the Sub Main area to update the sheet and Document, just as added insurance (but not sure if they would be necessary).
I edited the text file, then attached it to this response, to help a bit.
Wesley Crihfield
(Not an Autodesk Employee)
Hi @GosponZ. I think I see one problem in the code I attached above. I originally did not include the whole 'AddPartsList' Function in there, so down at Lines 21 through Line 25, I was originally just going to show a message, then exit the rule, when no PartsList was either pre-selected, found, or Picked. Then I added Line 22 later, which is the line of code that runs that custom Function. When I made that change, I commented out Line 23 (where it shows the message), but did not comment out Line 24 (Return), when I should have. So, in cases where no existing PartsList was pre-selected, found, or picked, it is calling that 'add' method, but then immediately exiting the rule, before it gets to the line of code that runs the Function to auto fit the column widths.
If this is the only problem, then you can just delete Lines 23 & 24 (the MessageBox.Show & the Return), to solve this problem.
However, I should have also included one or two lines of code at the end of the Sub Main area to update the sheet and Document, just as added insurance (but not sure if they would be necessary).
I edited the text file, then attached it to this response, to help a bit.
Wesley Crihfield
(Not an Autodesk Employee)
Hi Wesley,
it makes error
Error on Line 24 : 'Is' operator does not accept operands of type 'Integer'. Operands must be reference or nullable types.
Hi Wesley,
it makes error
Error on Line 24 : 'Is' operator does not accept operands of type 'Integer'. Operands must be reference or nullable types.
Must have been a copy/paste error, because I was editing in Notepad, instead of in the iLogic rule editor. Try simply eliminating the space between 'Is' and 'Not', to it becomes 'IsNot'. That line should have looked like this:
If oPList IsNot Nothing Then
Since this is a pretty odd situation, with multiple ways to possibly select, or find, or create a PartsList, this is just making sure that a PartsList actually exists at this point, before attempting to auto fit its columns, to avoid the potential errors. Because it is possible that the 'AddPartsList' custom function returns 'Nothing', if something odd is encountered (such as no views on sheet, no border on sheet, could not find parameter, no style name selected, or error creating it).
Wesley Crihfield
(Not an Autodesk Employee)
Must have been a copy/paste error, because I was editing in Notepad, instead of in the iLogic rule editor. Try simply eliminating the space between 'Is' and 'Not', to it becomes 'IsNot'. That line should have looked like this:
If oPList IsNot Nothing Then
Since this is a pretty odd situation, with multiple ways to possibly select, or find, or create a PartsList, this is just making sure that a PartsList actually exists at this point, before attempting to auto fit its columns, to avoid the potential errors. Because it is possible that the 'AddPartsList' custom function returns 'Nothing', if something odd is encountered (such as no views on sheet, no border on sheet, could not find parameter, no style name selected, or error creating it).
Wesley Crihfield
(Not an Autodesk Employee)
No error that fixed one part of problem. It is inserting table and fit nice but once start rule it pop up list with different table style. No matter what to pick from list allways only one table insert.
No error that fixed one part of problem. It is inserting table and fit nice but once start rule it pop up list with different table style. No matter what to pick from list allways only one table insert.
I tryed all possible combination but either rule is doing nothing or inserting all the time same table even if is list with several different tables.
Question is if i run one rule to insert table, could it be another rule to pick select table? That will give me option to run 3rd rule to adjust columns
I tryed all possible combination but either rule is doing nothing or inserting all the time same table even if is list with several different tables.
Question is if i run one rule to insert table, could it be another rule to pick select table? That will give me option to run 3rd rule to adjust columns
Hi @GosponZ. I am having a difficult time understanding all the details about what you want to happen, and when, versus what is happening now, and when. There may be something lost in translation or something. The only thing I have to go by is the code within the text file I attached to Message 8 above, so if you have changed the code since then, can you please post the code you have now, so we can see it in its current state?
One thing that seemed awkward to me within your earlier code examples was using a multi-value UserParameter for the names of the possible PartsListStyles. This means that this specifically named UserParameter would need to not only exist within every drawing you want to use this code on, but it would also have to have all those same values available, and there would also need to be all of those PartsListStyle objects, as local copies, within each of those drawing files. That seems like a lot of preparation work, and seems like it may be possible for all of that to not be in place properly in every drawing you try this code on. As of the last code example I posted, if the multi-value parameter is not found, it will throw an error, then exit the rule. However, if it was found, but had no values in it, that would just exit the rule, without any error message or warning. And, if no value was chosen from the InputListBox, it would just exit the rule, without any message or warning. And, if a local copy of a PartsListStyle by that name was not found within that drawing, I am not sure if that would throw an error, but it should. I know it was designed to throw an error if there is a problem while trying to add a new PartsList to the sheet, due to the Try...Catch...End Try block, and the message on the Catch side. Just so you are aware, it is not enough to just have those styles available within the main styles library, their must also be a local copy of the style saved within the document, before anything in the document can use the style. If that is not the case within all of the drawings that you will be running this rule on, then you may need to add some code into this rule to create the needed local copies of those styles into the drawing before attempting to apply one of those styles to the PartsList.
Wait...I do think I see something wrong now. Within the 'AddPartsList' Function, after the PartsList is added, there is no line of code present to set the PartsList.Style property to the PartsListStyle it just obtained a few lines of code earlier. It is just setting the PartsList.Position property value, then returning that new PartsList to the 'calling' routine.
Add:
oPList.Style = oPListStye
...in there, just before this:
oPList.Position = oPoint
Wesley Crihfield
(Not an Autodesk Employee)
Hi @GosponZ. I am having a difficult time understanding all the details about what you want to happen, and when, versus what is happening now, and when. There may be something lost in translation or something. The only thing I have to go by is the code within the text file I attached to Message 8 above, so if you have changed the code since then, can you please post the code you have now, so we can see it in its current state?
One thing that seemed awkward to me within your earlier code examples was using a multi-value UserParameter for the names of the possible PartsListStyles. This means that this specifically named UserParameter would need to not only exist within every drawing you want to use this code on, but it would also have to have all those same values available, and there would also need to be all of those PartsListStyle objects, as local copies, within each of those drawing files. That seems like a lot of preparation work, and seems like it may be possible for all of that to not be in place properly in every drawing you try this code on. As of the last code example I posted, if the multi-value parameter is not found, it will throw an error, then exit the rule. However, if it was found, but had no values in it, that would just exit the rule, without any error message or warning. And, if no value was chosen from the InputListBox, it would just exit the rule, without any message or warning. And, if a local copy of a PartsListStyle by that name was not found within that drawing, I am not sure if that would throw an error, but it should. I know it was designed to throw an error if there is a problem while trying to add a new PartsList to the sheet, due to the Try...Catch...End Try block, and the message on the Catch side. Just so you are aware, it is not enough to just have those styles available within the main styles library, their must also be a local copy of the style saved within the document, before anything in the document can use the style. If that is not the case within all of the drawings that you will be running this rule on, then you may need to add some code into this rule to create the needed local copies of those styles into the drawing before attempting to apply one of those styles to the PartsList.
Wait...I do think I see something wrong now. Within the 'AddPartsList' Function, after the PartsList is added, there is no line of code present to set the PartsList.Style property to the PartsListStyle it just obtained a few lines of code earlier. It is just setting the PartsList.Position property value, then returning that new PartsList to the 'calling' routine.
Add:
oPList.Style = oPListStye
...in there, just before this:
oPList.Position = oPoint
Wesley Crihfield
(Not an Autodesk Employee)
YEEES it is working now. Wesley, i appreciate, thanks a lot. Here is final code.
YEEES it is working now. Wesley, i appreciate, thanks a lot. Here is final code.
Can't find what you're looking for? Ask the community or share your knowledge.