Inventor Engineer-To-Order (Read-Only)
Welcome to Autodesk’s Inventor ETO Forums. Share your knowledge, ask questions, and explore popular Inventor ETO topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Find view object on the drawing through API.

15 REPLIES 15
Reply
Message 1 of 16
Lesoux
1270 Views, 15 Replies

Find view object on the drawing through API.

I wanna create the ordinate dimansion on the drawing.

 

Add(Intent As GeometryIntent, TextOrigin As Point2d, DimensionType As DimensionTypeEnum, ByRef DimensionStyle As [optional] VARIANT, ByRef Layer As [optional] VARIANT, Result As [out, retval] OrdinateDimension*)

How I can define GeometryIntent for function that was specified above.

All examples at the Inventor API Help is based on selection objects manually.

I wanna create the ordinate dimasions automatically. For this I need find/define the edge on the drawing view.

Win10 x64
Xeon E5-1630
32 Gb RAM
Quadro K5200

Inventor 2020.3.4, Build 373
15 REPLIES 15
Message 2 of 16
AlexKorzun
in reply to: Lesoux

Hi,

 

Indexer Property DrawingView.DrawingCurves may help you get the drawing curves enumerator that corresponds to the particular edge.

 

 

 

Thank you,




Alex Korzun
Inventor-Revit Interop / Inventor-Fusion Interop / Inventor ETO
Autodesk, Inc.

Message 3 of 16
Lesoux
in reply to: AlexKorzun

Dim oInvApp As Any = %%InventorApplication
Dim oDrawDoc As Any = oInvApp.ActiveDocument
Dim oSheet As Any = oDrawDoc.ActiveSheet
Dim oDrawViews As Any = oSheet.DrawingViews
Dim oDrawView As Any = oDrawViews.get_Item(1)
Dim oDrawingCurve As Any = oDrawView.DrawingCurves.get_Item(1)

 

Source code doesn't compile. I have the error message (see attached picture)

Win10 x64
Xeon E5-1630
32 Gb RAM
Quadro K5200

Inventor 2020.3.4, Build 373
Message 4 of 16
AlexKorzun
in reply to: Lesoux

Hi,

 

The DrawingCurves is the indexer property, Having the following Rule for finding the View (and the ISO view of the block+cone in it):

 

Rule FindView As Any
	Dim oInvApp As Any = %%InventorApplication
	Dim oDrawDoc As Any = oInvApp.ActiveDocument
	Dim oSheet As Any = oDrawDoc.ActiveSheet
	Dim oDrawViews As Any = oSheet.DrawingViews
	Dim oDrawView As Any = oDrawViews.get_Item(1)
	Return oDrawView
End Rule

 you may access:

 

1) All curves:

Intent >FindView.get_DrawingCurves().Count
--> 13

2) Specific occurrence ( should use GetHostObject())

Intent >FindView.get_DrawingCurves(GetHostObject(ivBlock_1)).Count
--> 9

 

 

 

 

 


Thank you,




Alex Korzun
Inventor-Revit Interop / Inventor-Fusion Interop / Inventor ETO
Autodesk, Inc.

Message 5 of 16
Lesoux
in reply to: AlexKorzun

Perfect, everything is Okay! Thanks for reply.

Win10 x64
Xeon E5-1630
32 Gb RAM
Quadro K5200

Inventor 2020.3.4, Build 373
Message 6 of 16
Lesoux
in reply to: AlexKorzun

When I tried to use GetHostObject() I got the error message (see attached picture). Do you know why?

 

{code}

Return InsertOrdinateDimension.get_DrawingCurves(GetHostObject(last(partObjectToDetail.assyChild))).Count

{code}

 

This is my Child on the Sheet

 

Child sheetChild As :myView
model = partObjectToDetail
...

{code}

...
End Child

 

<partObjectToDetail> is assembly that has next code:

 

Child assyChild As :myAdoptPart, Quantity = myQty

...
{code}

...
End Child


Win10 x64
Xeon E5-1630
32 Gb RAM
Quadro K5200

Inventor 2020.3.4, Build 373
Message 7 of 16
Lesoux
in reply to: Lesoux

Sorry, forgot about picture.

Win10 x64
Xeon E5-1630
32 Gb RAM
Quadro K5200

Inventor 2020.3.4, Build 373
Message 8 of 16
Lesoux
in reply to: AlexKorzun

The last questions.
Can I define DrawingCurve through API using names of edges from "Entity Naming Editor"? I don't know definitely indexes of curves on the drawing. I know just the names of edges.

 

Win10 x64
Xeon E5-1630
32 Gb RAM
Quadro K5200

Inventor 2020.3.4, Build 373
Message 9 of 16
AlexKorzun
in reply to: Lesoux

Hi,

 

Please have a look at the topic that discusses how faces store Intent attributes. The edges and vertices have the similar mechanism.

 

 

Thank you,




Alex Korzun
Inventor-Revit Interop / Inventor-Fusion Interop / Inventor ETO
Autodesk, Inc.

Message 10 of 16
Lesoux
in reply to: AlexKorzun

Thanks. Should work.

Win10 x64
Xeon E5-1630
32 Gb RAM
Quadro K5200

Inventor 2020.3.4, Build 373
Message 11 of 16
Lesoux
in reply to: Lesoux

Sometimes "getHostObject(me)" returns a document and other times a componentOccurrence.

When "getHostObject(me)" returns componentOccurrence, no issues, everything works. In other case I have this error message. How can I resolve this issue?

 

 

 

1.jpg

Win10 x64
Xeon E5-1630
32 Gb RAM
Quadro K5200

Inventor 2020.3.4, Build 373
Message 12 of 16
AlexKorzun
in reply to: Lesoux

Hi,

 

GetHostObject returns .Net reference to ComponentOccurence (or proxy to it) for the occurrences inside of assembly. For top level document (Root Part), the reference to the assembly document is returned.

Drawing document reference is returned for the IvDrawingDocument Intent Part.

 

I can guess from your refchain that you are attempting to call .Net in the context of some annotation on the drawing view. Depending on the view's Model, you may have to adjust proxy context first, and then figure out the geometry in IPT document.

 

If you have the small dataset that shows your problem, you may send it to ADN.

 

At least, the knowledge of the call stack will be useful at this point.

Thank you,




Alex Korzun
Inventor-Revit Interop / Inventor-Fusion Interop / Inventor ETO
Autodesk, Inc.

Message 13 of 16
Lesoux
in reply to: AlexKorzun

The main goal in my case is specify entity for creating origin indicator. I want to select one part from assembly view to define all drawing curves just for this part.
If I create subassembly separately and drawing for her, GetHostObject(object as part) returns occuranceComponent.
If I create full assembly and drawing for the same subassembly, GetHostObject(object as part) returns document and I have error message that shown in the previous post.

But this error is not constant.

Win10 x64
Xeon E5-1630
32 Gb RAM
Quadro K5200

Inventor 2020.3.4, Build 373
Message 14 of 16
AlexKorzun
in reply to: Lesoux

Some general suggestions (not everything may be applicable, as the model is unknown to me):

 

1) Are you using Visual Studio for debugging your problem? If so, can you set a breakpoint in the suspicious place?

 

2) Disect the problem: Can you disable drawings generation? Does GetHostObject() return correct values in both asembly-only cases?

 

3) Write a workable VBA script with what you want to achieve. Then it will be easier to convert to Intent code.

 

4) Do you have a simple case that can be sent to ADN?

Thank you,




Alex Korzun
Inventor-Revit Interop / Inventor-Fusion Interop / Inventor ETO
Autodesk, Inc.

Message 15 of 16
Lesoux
in reply to: AlexKorzun

This is design for creating origin point on the drawing. I didn't have any problems before. May be it's not best code.

 

<%%DisplayName("Origin Indicator"), %%Icon("Drawing-Annotation-OriginIndicator.ico")> _
Design IvOriginIndicator : deRootCustomFeatures BasePart

'------------------------------
' PARAMETERS
'------------------------------

<%%Category("Inventor"), %%Prompt("Represents the drawing view whose model contains the entity/entities to attach Ordinate Dimension to") > _
Parameter Rule view As Part = (If Parent.IsKindOf?(:IvCommonViewMixin) Then Parent Else NoValue)

<%%Category("Inventor"), %%Prompt("The part containing the entity to attach Ordinate Dimension to") > _
Parameter Rule part1 As Part = NoValue

<%%Category("Inventor"), %%Prompt("The list of entity to Ordinate Dimension, within part")> _
Parameter Rule entity1 As String = NoValue

<%%Category("Inventor"), %%Prompt("Identifies the placement point on the entity"), %%choicesType("Name"), _
%%choices(":startPoint, :endPoint, :midPoint, :circularCenterPoint, :circularLeftPoint, :circularRightPoint, :circularTopPoint, :circularBottomPoint")> _
Parameter Rule intent1 As Name = Required

<%%Category("Inventor"), %%Prompt("Sets whether the Origin Indicator should be hidden")> _
Parameter Rule originIndicatorVisible? As Boolean = True

'------------------------------
' PRIVATE RULES
'------------------------------

Rule oInvApp As Any = %%InventorApplication
Rule oActiveDoc As Any = oInvApp.ActiveDocument
Rule oActiveSheet As Any = oActiveDoc.ActiveSheet
Rule oDrawViewsSet As Any = oActiveSheet.DrawingViews

' Returns the specified view from the views on the drawing
Rule oView As Any
For i = 1 To oDrawViewsSet.Count
If oDrawViewsSet.get_Item(i).Name = viewName Then
oView = oDrawViewsSet.get_Item(i)
End If
Next
End Rule

' Returns the drawing curve within the drawing view filtered to the input model object
Rule oEdge As Any
Dim oObject As Any
If part1 <> NoValue Then
oObject = GetHostObject(part1).NativeObject ' the issue is in this row.

Else
oObject = NoValue
End If

Dim iObjQty As Integer = oView.get_DrawingCurves(oObject).Count
For i = 1 To iObjQty
Dim oEdgeP As Any = oView.get_DrawingCurves(oObject).get_Item(i).ModelGeometry
Dim oTempEdge As Any

If oEdgeP <> NoValue Then
oTempEdge = oEdgeP.NativeObject
End If

Dim oEdgeAttrSets As Any = oTempEdge.AttributeSets
Dim bEdgeAttrSetsIsUsedName? As Boolean = oEdgeAttrSets.get_NameIsUsed("Intent")
Dim oEdgeAttrSet As Any

If bEdgeAttrSetsIsUsedName? Then
oEdgeAttrSet = oEdgeAttrSets.get_Item("Intent")
Else
Exit For
End If

Dim bEdgeAttrSetIsUsedName? As Boolean = oEdgeAttrSet.get_NameIsUsed("Name")
Dim oEdgeAttr As Any

If bEdgeAttrSetIsUsedName? Then
oEdgeAttr = oEdgeAttrSet.get_Item("Name")
Else
Exit For
End If

If oEdgeAttr.Value = entity1 Then
Return oView.get_DrawingCurves(oObject).get_Item(i)
Exit For
End If
Next
End Rule

' Returns the intent point on the input geometry
Rule oIntentPoint As Any
Select(intent1)
Case :startPoint
oIntentPoint = oActiveSheet.CreateGeometryIntent(oEdge, Inventor.PointIntentEnum.kStartPointIntent)
Case :endPoint
oIntentPoint = oActiveSheet.CreateGeometryIntent(oEdge, Inventor.PointIntentEnum.kEndPointIntent)
Case :midPoint
oIntentPoint = oActiveSheet.CreateGeometryIntent(oEdge, Inventor.PointIntentEnum.kMidPointIntent)
Case :circularCenterPoint
oIntentPoint = oActiveSheet.CreateGeometryIntent(oEdge, Inventor.PointIntentEnum.kCenterPointIntent)
Case :circularRightPoint
oIntentPoint = oActiveSheet.CreateGeometryIntent(oEdge, Inventor.PointIntentEnum.kCircularLeftPointIntent)
Case :circularLeftPoint
oIntentPoint = oActiveSheet.CreateGeometryIntent(oEdge, Inventor.PointIntentEnum.kCircularRightPointIntent)
Case :circularTopPoint
oIntentPoint = oActiveSheet.CreateGeometryIntent(oEdge, Inventor.PointIntentEnum.kCircularTopPointIntent)
Case :circularBottomPoint
oIntentPoint = oActiveSheet.CreateGeometryIntent(oEdge, Inventor.PointIntentEnum.kCircularBottomPointIntent)
End Select
End Rule

' Specifies whether the origin indicator for ordinate dimensions has been created
' If the origin indicator has not been created -> Create the origin indicator -> Make the origin indicator visible/invisible
' If the origin indicator has been created -> Make the origin indicator visible/invisible
Rule Coord As Any
If Not oView.HasOriginIndicator Then
oView.CreateOriginIndicator(oIntentPoint)
oView.OriginIndicator.Visible = originIndicatorVisible?
Else
oView.OriginIndicator.Visible = originIndicatorVisible?
End If

Return oView.OriginIndicator.Intent.PointOnSheet
End Rule

'------------------------------
' CHILDREN
'------------------------------

Child OriginIndicator As :BasePart
render? = ((oView <> NoValue) And (oEdge <> NoValue) And (oIntentPoint <> NoValue) And (Coord <> NoValue))
showInModelBrowser? = False
End Child

Win10 x64
Xeon E5-1630
32 Gb RAM
Quadro K5200

Inventor 2020.3.4, Build 373
Message 16 of 16
Lesoux
in reply to: Lesoux

I have fixed my issue.

Need to replace:

 

Dim oObject As Any
If part1 <> NoValue Then
oObject = GetHostObject(part1).NativeObject 

Else
oObject = NoValue
End If

 

on

 

Dim oObject As Any
Dim oCompDef As Any = oView.ReferencedDocumentDescriptor.ReferencedDocument.ComponentDefinition
Dim oOccur As Any = oCompDef.Occurrences

If part1 <> NoValue Then
If GetHostObject(part1).Type = Inventor.ObjectTypeEnum.kComponentOccurrenceProxyObject Then
oObject = GetHostObject(part1).NativeObject
Else
For i = 1 To oOccur.Count
If part1.occurrenceName = oOccur.get_Item(i).Name Then
oObject = oOccur.get_Item(i)
Else
oObject = NoValue
End If
Next
End If
Else
oObject = NoValue
End If

Win10 x64
Xeon E5-1630
32 Gb RAM
Quadro K5200

Inventor 2020.3.4, Build 373

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report