Message 1 of 5
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello together,
i try to convert this ilogic to C#
'catch and skip errors On Error Resume Next 'define the active assembly Dim oAssyDoc As AssemblyDocument oAssyDoc = ThisApplication.ActiveDocument 'get user input as True or False wfBoolean = InputRadioBox("Turn all Sketches On/Off", "On", "Off", False, "iLogic") ' Process the rule, wrapping it in a transaction so the ' entire process can be undone with a single undo operation. Dim trans As Transaction trans = ThisApplication.TransactionManager.StartTransaction( _ oAssyDoc, "Sketches Off") 'Check all referenced docs Dim oDoc As Inventor.Document For Each oDoc In oAssyDoc.AllReferencedDocuments 'set Sketch visibility For Each oSketch In oDoc.ComponentDefinition.Sketches oSketch.Visible = wfBoolean Next Next 'end transaction for single undo trans.End 'upate the files InventorVb.DocumentUpdate()
The Problem is to get access to the activedocument compdefinitionobject.
in ilogic they know inventor.Document. But in C# its not possible to access trough Inventor.Document object.
public void HideSketches() { bool result = false; if (result == true) { Inventor.Transaction oTrans = myCad.InvApp.TransactionManager.StartTransaction(myCad.InvApp.ActiveDocument, "Sketches off"); foreach (Inventor.Document oDoc in myCad.InvApp.ActiveDocument.AllReferencedDocuments) { foreach (Inventor.Sketch oSketch in oDoc.ComponentDefinition.Sketches) { oSketch.Visible = result; } } oTrans.End(); oDoc.Update(); } }
i used a bool for testing, later i will implement the dialog. The Problem here is, the linepart oDoc.componentDefinition is not possible.
i have the same problem in a lot of codesnippets. where the actual DocType is not clear while programming.
Please help.
THanks
If my reply was helpful, please give a "Kudo" or click the "Accept as Solution" button below (or both).
Solved! Go to Solution.