Is it possible to use iLogic Interfaces With .NET Add-ins?

Is it possible to use iLogic Interfaces With .NET Add-ins?

Anonymous
Not applicable
595 Views
1 Reply
Message 1 of 2

Is it possible to use iLogic Interfaces With .NET Add-ins?

Anonymous
Not applicable

Hi all,

 

I have been trying to figure this out for the past few days without much luck. I'm working on converting a large amount of drawing automation code from iLogic over to C#, and I was hoping to be able to use some of the methods available to iLogic that are not directly available in the Inventor API, such as ICadDrawingView.SetSpacingToCorner. I've tried casting the active drawing document as an ICadDrawing, but that threw an invalid cast exception. I have already dug through the iLogic API documentation and looked at the help that is out there for using the iLogic Automation interface, but there doesn't seem to be anything out there as far as I can tell indicating if this is even possible.

 

I wrote a method to get all of the drawing views from the drawing document I'm working with so I could feed all of the drawing view objects to following methods such as the one below. I know it's possible to get the same functionality out of the Inventor API, but with how convenient some of the built-in iLogic methods are to get the same task completed I would really like to be able to get access to them if possible.

 

I know that I could pack this all into an iLogic rule and run it externally, but I've been tasked with getting as much as possible into .NET so we can have this whole system under our source control system and available for any of our other developers to work with and use, so I am not considering that as an option for these larger methods.

 

If anyone has some insight into how I could get this working I would appreciate it. I'm familiar with coding in VB as well, so if anyone has an example of how to get this to work in VB that would be just as helpful.

 

 

private void ViewScalingAndPlacement(ICadDrawing drawingDocument, ICadDrawingView leftView, ICadDrawingView planeView, ICadDrawingView trapLayout, ICadDrawingView inletView, ICadDrawingView driveView, ICadDrawingView a1u, ICadDrawingView a9u, ICadDrawingView squareLayout, ICadDrawingView oSF, ICadDrawingView oF, ICadDrawingView iBF, ICadDrawingView iF, ICadDrawingView planeView2)
        {
            double sheetHeight = drawingDocument.ActiveSheet.Sheet.Height;
            double viewHeight = sheetHeight - (8 * 24.2);
            double overallHeight = leftView.Height + planeView.Height + trapLayout.Height;
            double viewScale = leftView.Scale;

            if (overallHeight > viewHeight)
            {
                while(overallHeight > viewHeight)
                {
                    leftView.Scale = viewScale - 0.01;
                    overallHeight = leftView.Height + planeView.Height + trapLayout.Height;
                    viewScale = leftView.Scale;
                }
            }
            else if (overallHeight < viewHeight)
            {
                while (overallHeight < viewHeight)
                {
                    leftView.Scale = viewScale + 0.01;
                    overallHeight = leftView.Height + planeView.Height + trapLayout.Height;
                    viewScale = leftView.Scale;
                }
            }            
            double heightSpacing = drawingDocument.ActiveSheet.Height;
            double widthSpacing = drawingDocument.ActiveSheet.Width;
            double leftViewWidth = leftView.Width;

            //use the iLogic spacing and center methods to position the drawing views
            leftView.SetSpacingToCorner((widthSpacing / 4) * 2, leftViewWidth / 2, SheetCorner.BottomLeft);

            inletView.SetSpacingToCorner(1.25, heightSpacing / 4 * 2, SheetCorner.BottomLeft);

            driveView.SetSpacingToCorner(1.625, heightSpacing / 4 * 2, SheetCorner.BottomRight);

            a1u.SetSpacingToCorner(widthSpacing / 4, 0.625, SheetCorner.BottomLeft);

            a9u.SetSpacingToCorner(widthSpacing / 4, 0.625, SheetCorner.BottomLeft);

            squareLayout.SetSpacingToCorner(widthSpacing / 4 * 2, 1.0, SheetCorner.BottomLeft);

            trapLayout.SetSpacingToCorner(widthSpacing / 4 * 2, 1.0, SheetCorner.BottomLeft);

            planeView.SetSpacingToCorner(widthSpacing / 4 * 2, 1.0, SheetCorner.TopLeft);

            oSF.SetCenter(27, 18);

            oF.SetCenter(27, 18);

            iBF.SetCenter(7, 18);

            iF.SetCenter(7, 18);

            planeView2.View.Suppressed = true;
        }

 

 

0 Likes
596 Views
1 Reply
Reply (1)
Message 2 of 2

chandra.shekar.g
Autodesk Support
Autodesk Support

@Anonymous,

 

All functions of iLogic code are written on top of Inventor API. In general, any Function in iLogic code are consists of many Inventor API functions or properties. To program in C# language, need to understand VBA samples. Which can explain the working of many Inventor API.

 

For reference, go through below link for VBA samples.

 

http://help.autodesk.com/view/INVNTOR/2021/ENU/?guid=GUID-DE98632B-3DC0-422B-A1C6-8A5A15C99E11

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes