In my previous post I discovered that it’s impossible to name geometry in an assembly. That also means that I can’t create dimensions from geometry in a assembly. There for I need a function that gets curves from geometry in a assembly and create an intent for it. With that i can create dimensions on an assembly drawing

I have to make a nuance on my previous post. Although it’s not possible to add named geometry to an assembly there is a work around. It’s possible to get an intent for a drawing curve created by model geometry which is in a component within the assembly document. This is done with an overloaded function of “GetIntent()”. More information can be found in the online iLogic help file. But I still would like to use named geometry in an assembly. In this post I will show how that can be done.

My first problem is that I can’t add the attributes to the assembly with the “Assign Name” function like in parts models. For now I will solve that by adding the attributes with the “Nifty attribute addon (by ekinssolutions.com)”. But what attributes to add. I can use the same attribute names as in the part models. But that will get me in trouble with the official iLogic functions. (See my previous post.) Therefor I decided that I will use the following names:

Attribute set name: “iLogicEntityNameSet”
Attribute Name: “iLogicProxyEntityName”

Now I know how to prepare my assembly model. Now it'stime to writing code. The code that I’m writing will be used in multiple drawings. Therefore, I will create a external rule so I can reuse it when I need. Later I will probably add this to a dll together with other functions that I often use. Then it is convenient if this becomes an extension of the iLogic object “IManagedDrawingView”. Then I can use the same object to call the original “GetIntent()” function and my new function “GetProxyIntent()”. (If you are wondering where this “Proxy” comes from: In assemblies there are none real face/edge objects. There are only models with faces. There for Autodesk invented ProxyFace/Edge objetcs. They act as a proxy for the real face or edge.) Here is the external rule “IManagedDrawingViewExtensions.iLogicVb” that I created

Imports Inventor
Public Module IManagedDrawingViewExtensions
    <Runtime.CompilerServices.Extension()>
    Public Function GetProxyIntent(managedView As Autodesk.iLogic.Interfaces.IManagedDrawingView, name As String, Optional Intent As Object = Nothing) As GeometryIntent
        Dim view As DrawingView = managedView.View
        Dim model As Document = view.ReferencedDocumentDescriptor.ReferencedDocument

        Dim objs As ObjectCollection = model.AttributeManager.FindObjects("iLogicEntityNameSet", "iLogicProxyEntityNameSet", name)

        If (objs.Count <> 1) Then
            Throw New Exception(objs.Count & " object found with name: " & name)
        End If
        Dim obj = objs.Item(1)

        Dim curves = view.DrawingCurves(obj)

        If (curves.Count = 0) Then
            Throw New Exception("None DrawingCurve found for entity: " & name)
        End If

        Dim curve As DrawingCurve = curves.Item(1)

        Return view.Parent.CreateGeometryIntent(curve, Intent)
    End Function
End Module

You need to set this rule as “Straight VB code” or it will not work.

To be fair, this entire code is on the brink of what's possible with iLogic. While writing this rule I have come a cross dialogs that I have never seen before. Like this one:

(There is something wrong with this dialog…)

Anyway, as far as I could test this it works. Here is an example code that uses the new function:

AddVbFile "\IManagedDrawingViewExtensions.iLogicVb"
Dim Sheet_1 = ThisDrawing.Sheets.ItemByName("SHEET:1")
Dim VIEW1 = Sheet_1.DrawingViews.ItemByName("VIEW1")

Dim intent1 As GeometryIntent = VIEW1.GetProxyIntent("dim1")
Dim intent2 As GeometryIntent = VIEW1.GetProxyIntent("dim2")

Dim genDims = Sheet_1.DrawingDimensions.GeneralDimensions

ThisDrawing.BeginManage()
If True Then 
	Dim linDim3 = genDims.AddLinear("Dimension 1", VIEW1.SheetPoint(0.5, 1.5), intent1, intent2)
End If
ThisDrawing.EndManage()

The code adds 1 dimension to VIEW1 on SHEET:1. This is almost only iLogic code. Except for the first line. That line tells iLogic to add/load the external rule with the extension code. And on line 5 and 6 the new extended function are used.

This is all you need to create dimensions on your drawing. But you will need to add the attributes manualy with the "Nifty Attribute" addon. Also it would be more convenient if it was possible to show labels like the official labels. I will recreate those functions and write about it in the following posts.

Edit 1:
Updated messages of exceptions that are thrown

 

Skills:

Autodesk Inventor, Vault, Git, C#, vb, .net, php HTML, css, js

Education:

University computer science.
HBO Mechanical engineer.
MBO Fine mechanics.

Experience:

Programmer and Mechanical engineer at Kelvion
(2016 - 20..)

Mechanical engineer at Strukton
(2009 - 2016)

Mechanical engineer at RDG-engineering
(2007 - 2009)

CNC Programmer at VMC
(2005 - 2007)

volunteer at Taizé
(2007)

Certifications:

Objectgeoriënteerd analyseren en ontwerpen, Objectgeoriënteerd programmeren in Java, Webapplicaties: de clientkant, Databases, Security Aware Programmer, Web Security Specialist