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.
Hi,
Indexer Property DrawingView.DrawingCurves may help you get the drawing curves enumerator that corresponds to the particular edge.
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)
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
Perfect, everything is Okay! Thanks for reply.
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
Sorry, forgot about picture.
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.
Thanks. Should work.
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?
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.
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.
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?
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
I have fixed my issue.
Need to replace:
Dim oObject As AnyIf part1 <> NoValue ThenoObject = GetHostObject(part1).NativeObject
ElseoObject = NoValueEnd 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