iLogic - run drawing rule in assembly

iLogic - run drawing rule in assembly

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

iLogic - run drawing rule in assembly

Anonymous
Not applicable

I'm working on automating some processes for a standard product. I have created an iAssembly and are using ilogic to generate a drawing from the iAssembly which creates some views. I've managed to create some ilogic rules in the drawing template to add some model dimensions using workpoints. But I don't know how to run the drawing rules from the assembly rule? If I try to run the dimensions rules from the assembly I only get a message saying the active document is not a drawing. Anyone know how I can solve this, or point me in the right direction?

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

MechMachineMan
Advisor
Advisor

1. The run rule methods that reference a specific document.

 

2. Using "ThisDoc.Document" in your rules instead of "ThisApplication.ActiveDocument"


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 3 of 3

Anonymous
Not applicable

Hi, thanks for the reply. I’m quite new to this, but here’s what I try to achieve:

 

  • Configure a model with iParts/iAssemblies using an iLogic form (this part is OK)
  • Generate an .idw drawing of the selected iAssembly row, which creates views and adds some dimensions

 

The “generate drawing” function works, when running from the assembly file. And the “add dimensions” works when running the rule from the drawing. But, I’m having trouble melting these togheter. I get an error saying error “ThisDrawing: This document "iassemblylogic2" is not a drawing.”  Could someone help me in the right direction?

 

I have also have a couple of question about further possibilities:

  • Is it possible to add balloons using iLogic?
  • I use “Dim oModelName As String = "location\filename.iam". But isn’t it possible to just use the current assembly without specifying filename, so this can be a general rule?
Dim oModel As Document
Dim oSheet As Sheet
Dim oModelName As String = "location\file.iam"

oModel= ThisApplication.Documents.Open(oModelName, False)

	'Determine the drawing template
	Dim IDWTemplate As String = "location\template.idw"
	
	'Create a drawing
	oDrawingDoc = ThisApplication.documents.Add(DocumentTypeEnum.kDrawingDocumentObject, IDWtemplate, True)
	oDrawingDoc.Activate()
	oSheet = oDrawingDoc.Sheets.Item(1)
	
	'Create base view
	Dim oPoint1 As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(25,40)

	oBaseView = oSheet.DrawingViews.AddBaseView(oModel, oPoint1, 0.2, ViewOrientationTypeEnum.kLeftViewOrientation, DrawingViewStyleEnum.kHiddenLineDrawingViewStyle)
	
	Dim oPoint2 As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(60,40)
	Dim otopview As DrawingView
	
	otopview = oSheet.DrawingViews.AddProjectedView(oBaseView, oPoint2, DrawingViewStyleEnum.kFromBaseDrawingViewStyle)


'Adding dimensions
       

        Dim oView As DrawingView = ActiveSheet.View("VIEW1").View
        Dim oDoc As Document = oView.ReferencedDocumentDescriptor.ReferencedDocument
        
        Dim oGeomIntent1 As Inventor.GeometryIntent
        Dim oGeomIntent2 As Inventor.GeometryIntent

        Dim oWP1 As Inventor.WorkPoint = oDoc.ComponentDefinition.WorkPoints.Item("WP1")
        Dim oWP2 As Inventor.WorkPoint = oDoc.ComponentDefinition.WorkPoints.Item("WP2")

        
        oView.SetIncludeStatus(oWP1, True)
        oView.SetIncludeStatus(oWP2, True)


        Dim oCenterMark1 As Inventor.Centermark
        Dim oCenterMark2 As Inventor.Centermark
        Dim oCenterMark As Inventor.Centermark

        For Each oCenterMark In oSheet.Centermarks

            If oCenterMark.Attached Then
                If oCenterMark.AttachedEntity Is oWP1 Then
                
                    oCenterMark1 = oCenterMark
                End If
                If oCenterMark.AttachedEntity Is oWP2 Then
                    oCenterMark2 = oCenterMark
                    
                End If
            End If
        Next
        
        oGeomIntent1 = oSheet.CreateGeometryIntent(oCenterMark1, kPoint2dIntent)
        oGeomIntent2 = oSheet.CreateGeometryIntent(oCenterMark2, kPoint2dIntent)
        
        oCenterMark1.Visible = False
        oCenterMark2.Visible = False
        
        Dim textPoint As Inventor.Point2d = ThisServer.TransientGeometry.CreatePoint2d(40,40)
        Dim oDim as GeneralDimension = oSheet.DrawingDimensions.GeneralDimensions.AddLinear(textPoint, oGeomIntent1, oGeomIntent2, DimensionTypeEnum.kVerticalDimensionType)
0 Likes