AddAngularforeshotened method doesn't work

AddAngularforeshotened method doesn't work

Geertvdheide92
Enthusiast Enthusiast
907 Views
3 Replies
Message 1 of 4

AddAngularforeshotened method doesn't work

Geertvdheide92
Enthusiast
Enthusiast

Hi, 

 

I want to add an angular foreshortened dimension in a drawing

Geertvdheide92_0-1601969780774.png

 

This should be possible with the AddAngularForeshortened function.

 

Situation:

First i select a drawingcurve, added by including a skecth from the assembly. this is a drawingcurve object.

second i select the centermark. (Centermark object.)

in the code i am creating a line the represents the vertical line of the centermark, going up. 

 

the objects should have the right type but the i get an error when i add the dimension. 

I tried the code with 2 drawingcurve object and this worked, but somehow i can't get the centermark line to work. 

 

Is there any way to get this to work with a drawingcurve and a centermark?

Sub CreateAngularForeshortenedDim
    ' Open a drawing document and select two parallel linear curves in same drawing view first.
    Dim oApp As Inventor.Application
    Set oApp = ThisApplication
    
    Dim oDoc As DrawingDocument
    Set oDoc = oApp.ActiveDocument

    Dim oCurve1 As DrawingCurve, oCurve2 As Centermark
    Set oCurve1 = oDoc.SelectSet(1).Parent
    Set oCurve2 = oDoc.SelectSet(2)
    
    Dim oSheet As Sheet
    Set oSheet = oDoc.ActiveSheet
     
    Dim oLine As Line2d
    Set oLine = oApp.TransientGeometry.CreateLine2d(oCurve2.Position, oCurve2.ExtensionPointTwoDirection)
    
    Dim oAngle As Boolean
    oAngle = False
    
    ' Create two GeometryIntent based on the selected drawing curve segments.
    Dim oIntent1 As GeometryIntent, oIntent2 As GeometryIntent, oIntent3 As GeometryIntent
    Set oIntent1 = oSheet.CreateGeometryIntent(oCurve1)
    Set oIntent2 = oSheet.CreateGeometryIntent(oLine)
    Set oIntent3 = oSheet.CreateGeometryIntent(oCurve2)
    
    Dim oTextPos As Point2d
    Set oTextPos = oApp.TransientGeometry.CreatePoint2d(20, 30)
    
    ' Create the foreshortened dimension
    Dim oAngularForeshortenedDim As AngularGeneralDimension
    Set oAngularForeshortenedDim = oSheet.DrawingDimensions.GeneralDimensions.AddAngularForeshortened(oTextPos, oIntent1, oIntent2, , True, True, False)
End Sub

 

Kind regards, 

 

Geert

0 Likes
Accepted solutions (1)
908 Views
3 Replies
Replies (3)
Message 2 of 4

WCrihfield
Mentor
Mentor

Perhaps instead of creating a new transient Line2d object based on the Centermark's position and extension point 2 direction, you could just use one of the two centerlines within the centermark.  The centermark object has a centerlines property, which returns an ObjectCollection of Centerlines.  The 'items' within are defined as Object, so you may or may not have to redefine their type before using them, but one of those two centerlines should give you the needed second line to measure the angle between.  Also, the centerline of the centermark is a visible line on the drawing, while the transient Line2d object isn't, so that may also be key.

 

By the way, are you sure about the type of object being returned by your SelectSet(1).Parent?  Have you tried using a MsgBox to return the readable Type of the selected object, and/or its parent object?

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 4

Geertvdheide92
Enthusiast
Enthusiast

Hi, 

 

When i look at the centermark object i cannot find the centerlines. 

There is a property that is called centerlines, but is says the value is nothing. 

Does nothing mean it is a collection? because the only thing i can find are the extensionpoints.

 

the type of SelectSet(1) is a drawingcurve segment. the parent of the drawingcurve segment is the drawing curve. this curve can be used to create the geometry intent, but i don't think the curve segment can be used for this. 

 

als when you create geometry intent is this geometry intent visible? or is this just a reference to an existing line. 

Because i can use a line2D to create geometryintent. anyway, i don't get errors when the geometry intent is created.

 

i also found sort of another solution which requires base files to be adjusted. 

Because all the other lines are included from sketches, i think the easiest solution is to also include a centermark from the sketches, as this can be placed in a sketch that is always included 😉

0 Likes
Message 4 of 4

WCrihfield
Mentor
Mentor
Accepted solution

Maybe that Centerlines collection of the centermark will only contain centerlines when the ExtensionLinesVisible property is True, and the centermark style used to create the centermark specifies that it is large enough to need extension lines.  The documentation for these subjects aren't very clear.  Sorry to hear this tip/idea isn't going to work in your situation.

There are multiple ways to specify Intent.  Intent data is just information (and therefore not visible) about how the supplied geometry should be used by the target entities that are to be attached to them.  Almost always resulting in point type information obtained by one means or another.  It can get 'unnecessarily' complicated, due to all the possibilities and combinations.

Yes.  If all other geometry being dimension is being referenced from a sketch, including the point in the sketch seems like an obviously advantageous thing to do.  There have been several cases where we need to dimension between the intersections of drawing curves that don't actually intersect visibly in the drawing.  There are some 'pro tips' for dealing with some situations like this when manually placing dimensions, but of course things of this nature always seem more complex when trying to do them purely by code.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)