Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Possible to Check All Members of Factory for Errors using iLogic / VB?

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
danmorick
1654 Views, 4 Replies

Possible to Check All Members of Factory for Errors using iLogic / VB?

I have an iLogic rule that pages through all members of an ipart or iassembly, letting me see each one so that if it doesn't look "right", I can go back and fix it.

 

DimappAsInventor.Application=ThisApplication
DimoDocAsInventor.Document=app.ActiveDocument
DimoCompDefAsComponentDefinition=oDoc.ComponentDefinition
DimcurrowAsInteger
DimopFactoryAsiPartFactory
DimopRowAsiPartTableRow

InventorVb.DocumentUpdate()

opFactory=ThisApplication.ActiveDocument.ComponentDefinition.iPartFactory
currow=opFactory.DefaultRow.Index
opFactory.DefaultRow=opFactory.TableRows.Item(1)
' Iterate through the rows
ForEachopRowInopFactory.TableRows
opFactory.DefaultRow=opRow
Next
opFactory.DefaultRow=opFactory.TableRows.Item(currow)

Now I'd like to take it a little further.  If one of the members has an error of some kind - a feature that can't compute, or constraints that are in conflict, anything that would cause Design Doctor to pop up - I'd like the rule to stop running at that problem member and allow the user to correct it on the spot.

 

I know I can call the Design Doctor:

ThisApplication.CommandManager.ControlDefinitions.?Item("AppDesignDoctorCmd").Execute()

but I don't know how or if I can read some value related to Design Doctor that tells me whether it wants to pop up.  My code currently just activates each member and continues regardless of whether there is an error.  When the code activates a problem member, the red cross doesn't highlight to indicate a problem; however, if I were to activate that member manually, Design Doctor would be initiated.

 

Is there a way ( I would think so) to determine in the code whether a table member contains errors that would turn on the Design Doctor?  Do I need some kind of delay to allow Inventor to process and recognize problems in the table?

4 REPLIES 4
Message 2 of 5
adam.nagy
in reply to: danmorick

Hi,

 

Unfortunately, it seems that the ErrorManager does not collect the porblems with the model if the iPartRow is changed programmatically. One workaround I got from a colleague is doing the change through the user interface but silently, so that the information is collected but no dialog pops up:

' Suppose the iPart table has 3 rows, and the 3rd row has invalid data
Sub RetrieveErrorInfoOfiPartTableRow()
    Dim oErrorManager As ErrorManager
    Set oErrorManager = ThisApplication.ErrorManager
   
    Dim oDoc As PartDocument
    Set oDoc = ThisApplication.ActiveDocument
 
    Dim oiPart As iPartFactory
    Set oiPart = oDoc.ComponentDefinition.iPartFactory
   
    Dim oTop As BrowserNode
    Set oTop = oDoc.BrowserPanes("Model").TopNode
   
    Dim bHasErrorOrWarning As Boolean
    ThisApplication.SilentOperation = True
   
    ' Highlight the 3rd iPart table row which has invalid data
    oTop.BrowserNodes("Table").BrowserNodes.Item(3).DoSelect
   
    ' Activate the iPart table row
    Dim oCommand As ControlDefinition
    Set oCommand = ThisApplication.CommandManager.ControlDefinitions("PartComputeiPartRowCtxCmd")
    oCommand.Execute
   
    ThisApplication.SilentOperation = False
   
    If oErrorManager.HasErrors Or oErrorManager.HasWarnings Then
        MsgBox oErrorManager.LastMessage, vbOKCancel
    End If
End Sub

I hope this helps.

Cheers,



Adam Nagy
Autodesk Platform Services
Message 3 of 5
justfuz
in reply to: adam.nagy

This code loops thru the table, but I'm not sure what I need to add so that it will update the table with a custom parameter.

 

I have a sheet metal iPart that I want to have the FlatPatternExtentsArea to update the table value as it activates each row.

How or where do I need to add my code to this code?

 

Format:HTML Format Version:1.0 StartHTML: 165 EndHTML: 1864 StartFragment: 314 EndFragment: 1832 StartSelection: 314 EndSelection: 314 SyntaxEditor Code Snippet

iProperties.Value("Custom", "SQ_FT")=Round(SheetMetal.FlatExtentsArea/144,2)&" FT SQ"

Message 4 of 5
adam.nagy
in reply to: justfuz

Hi,

 

I think you should be able to modify the iPart table factory row to use the custom value you need, and then activate through the UI as shown in previous post: http://adndevblog.typepad.com/manufacturing/2013/02/manipulate-rows-and-columns-of-ipart-1.html

 

Cheers,



Adam Nagy
Autodesk Platform Services
Message 5 of 5
Cody.Redding
in reply to: adam.nagy

I had a similar issue, and here is what i came up with.  It exports all instances to AutoCAD DWG, but altering the File extension will change the format. 

 

Dim app As Inventor.Application = ThisApplication
Dim oDoc As Inventor.Document = app.ActiveDocument
Dim oCompDef As ComponentDefinition = oDoc.ComponentDefinition
Dim currow As Integer
Dim opFactory As iPartFactory
Dim opRow As iPartTableRow
Dim Max as Integer = 10

InventorVb.DocumentUpdate()

opFactory = ThisApplication.ActiveDocument.ComponentDefinition.iPartFactory
currow = opFactory.DefaultRow.Index
opFactory.DefaultRow = opFactory.TableRows.Item(1)

If opFactory.TableRows.Count > Max
	Proceed = MessageBox.Show("This will create " & opFactory.TableRows.Count & " files, and may take some time to execute.  Do you want to continue?  ", "Time Warning",MessageBoxButtons.YesNo,MessageBoxIcon.Warning)
Else
	Proceed = vbYes
End If

If Proceed = vbYes
	' Iterate through the rows
	For Each opRow In opFactory.TableRows
		opFactory.DefaultRow=opRow
		ThisDoc.Document.SaveAs(ThisDoc.Path & "\" & ThisDoc.FileName(False) & "\" & ThisDoc.FileName(False) & " - " & opRow.Index & ".dwg", True)
	'	MessageBox.Show(ThisDoc.Path & "\" & ThisDoc.FileName(False) & "\" & ThisDoc.FileName(False) & " - " & opRow.Index & ".dwg" , "")
	Next
	opFactory.DefaultRow=opFactory.TableRows.Item(currow)
End If

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report