Creating a Dimension between two workplanes in a drawing
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello everybody,
i'm about to create a fully automated drawing sheet. Until now I used WorkPoints for dimensions in the drawing. But now i want to add a Dimension between two WorkPlanes.
I tried to modify the code for my WorkPoints to make it suitable...
Here is the code i use for my WorkPoints:
Dim oSheet As Sheet = ThisDoc.Document.ActiveSheet
Dim oView As DrawingView = ActiveSheet.View("ANSICHT1").View
Dim oDoc As Document = oView.ReferencedDocumentDescriptor.ReferencedDocument
Dim oGeomIntent1 As Inventor.GeometryIntent
Dim oGeomIntent2 As Inventor.GeometryIntent
Dim oWP1 As Inventor.WorkPoint = oDoc.ComponentDefinition.WorkPoints(1)'.Item("WP_1")
Dim oWP2 As Inventor.WorkPoint = oDoc.ComponentDefinition.WorkPoints(2)'.Item("WP_2")
oView.SetIncludeStatus(oWP1, True)
oView.SetIncludeStatus(oWP2, True)
Dim oCenterMark1 As Inventor.Centermark
Dim oCenterMark2 As Inventor.Centermark
Dim oCenterMark As Inventor.Centermark
For Each oCenterMark In oSheet.Centermarks
If oCenterMark.Attached Then
If oCenterMark.AttachedEntity Is oWP1 Then
oCenterMark1 = oCenterMark
End If
If oCenterMark.AttachedEntity Is oWP2 Then
oCenterMark2 = oCenterMark
End If
End If
Next
oGeomIntent1 = oSheet.CreateGeometryIntent(oCenterMark1, kPoint2dIntent)
oGeomIntent2 = oSheet.CreateGeometryIntent(oCenterMark2, kPoint2dIntent)
oCenterMark1.Visible = False
oCenterMark2.Visible = False
Dim textPoint1 As Inventor.Point2d = ThisServer.TransientGeometry.CreatePoint2d(27.5,25)
Dim textPoint2 As Inventor.Point2d = ThisServer.TransientGeometry.CreatePoint2d(44,25)
Dim oDim1 as GeneralDimension = oSheet.DrawingDimensions.GeneralDimensions.AddLinear(textPoint1, oGeomIntent1, oGeomIntent2, DimensionTypeEnum.kHorizontalDimensionType)
Dim oDim2 as GeneralDimension = oSheet.DrawingDimensions.GeneralDimensions.AddLinear(textPoint2, oGeomIntent1, oGeomIntent2, DimensionTypeEnum.kVerticalDimensionType)
This code so far works fine, but when i modify it i get the error message:
System.Runtime.InteropServices.COMException (0x80004005): unknown error (Exception from HRESULT: 0x80004005 (E_FAIL))
at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
at Inventor.GeneralDimensions.AddLinear(Point2d TextOrigin, GeometryIntent IntentOne, Object IntentTwo, DimensionTypeEnum DimensionType, Boolean ArrowheadsInside, Object DimensionStyle, Object Layer)
at LmiRuleScript.Main()
at Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)
at iLogic.RuleEvalContainer.ExecRuleEval(String execRule)
Here is the part of the code i want to use for my WorkPlanes:
Dim oGeomIntent5 As Inventor.GeometryIntent
Dim oGeomIntent6 As Inventor.GeometryIntent
Dim oWP5 As Inventor.WorkPlane = oDoc.ComponentDefinition.WorkPlanes("XZ Plane")
Dim oWP6 As Inventor.WorkPlane = oDoc.ComponentDefinition.WorkPlanes("Work Plane1")
oView.SetIncludeStatus(oWP5, True)
oView.SetIncludeStatus(oWP6, True)
oGeomIntent5 = oSheet.CreateGeometryIntent(oWP5, kStartPointIntent)
oGeomIntent6 = oSheet.CreateGeometryIntent(oWP6, kEndPointIntent)
Dim textPoint4 As Inventor.Point2d = ThisServer.TransientGeometry.CreatePoint2d(20,25)
Dim oDim4 as GeneralDimension = oSheet.DrawingDimensions.GeneralDimensions.AddLinear(textPoint4, oGeomIntent5, oGeomIntent6, DimensionTypeEnum.kVerticalDimensionType)i never saw an example of an dimension-code between two workplanes so i tried out a lot of modifications, but there was always this error message i mentioned...
Does someone has experience with this type of dimensions?
thanks in advance,
Lorenz
