Ilogic Chain Dimensions

Ilogic Chain Dimensions

Anonymous
Not applicable
931 Views
2 Replies
Message 1 of 3

Ilogic Chain Dimensions

Anonymous
Not applicable

I have a part the contains up to four rows of holes depending on the overall height of the part (e.g 1,2,3 or 4 rows) and I trying to use iLogic to automatically create vertical chain dimension depending on that height. I've found a snippet of code for this (see below), but it's only in vba and I don't know how to convert it. Thanks.

 

 

Public Function DimToWorkPoints(ByVal DrawView As DrawingView, _ ByVal WorkPoint1 As WorkPoint, _ ByVal WorkPoint2 As WorkPoint, _ ByVal TextPosition As Point2d, _ ByVal AlignmentType As DimensionAlignmentTypeEnum) As GeneralDimension

 

Try

 

Dim sheet As Sheet sheet = DrawView.Parent

 

' Create centermarks based on the work points. Dim marks(1) As Centermark marks(0) = sheet.Centermarks.AddByWorkFeature(WorkPoint1, DrawView) marks(0).Visible = False marks(1) = sheet.Centermarks.AddByWorkFeature(WorkPoint2, DrawView) marks(1).Visible = False

 

' Create geometry intents for the center marks. Dim intent1 As GeometryIntent intent1 = sheet.CreateGeometryIntent(marks(0)) Dim intent2 As GeometryIntent intent2 = sheet.CreateGeometryIntent(marks(1))

 

' Add a dimension. Dim genDim As GeneralDimension genDim = sheet.DrawingDimensions.GeneralDimensions.AddLinear(TextPosition, _ intent1, intent2, AlignmentType) Return gen

Dim Catch ex As Exception

Return Nothing

End Try

End Function

0 Likes
932 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable

I've changed the code to this but get the error:

 

The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))

 

SyntaxEditor Code Snippet

'---Initial Setup---

Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument

Dim oSheet As Sheet
oSheet = oDrawDoc.ActiveSheet

Dim oView As DrawingView
oView = ActiveSheet.View("FLAT PATTERN").View

Dim oPartDoc As PartDocument
oPartDoc = ActiveSheet.View("FLAT PATTERN").ModelDocument

Dim WorkPoint1 As WorkPoint = oPartDoc.ComponentDefinition.WorkPoints(1)
Dim WorkPoint2 As WorkPoint = oPartDoc.ComponentDefinition.WorkPoints(2)
Dim WorkPoint3 As WorkPoint = oPartDoc.ComponentDefinition.WorkPoints(3)
Dim WorkPoint4 As WorkPoint = oPartDoc.ComponentDefinition.WorkPoints(4)
Dim WorkPoint5 As WorkPoint = oPartDoc.ComponentDefinition.WorkPoints(5)

'---Dimension Prep---

'Create centermarks based on the work points. 
Dim oCenterMark(1) As Centermark
oCenterMark(0) = oSheet.Centermarks.AddByWorkFeature(WorkPoint1, oView)
oCenterMark(1) = oSheet.Centermarks.AddByWorkFeature(WorkPoint2, oView)

'Create geometry intents for the center marks. 
Dim intent1 As GeometryIntent
intent1 = oSheet.CreateGeometryIntent(oCenterMark(0))
Dim intent2 As GeometryIntent
intent2 = oSheet.CreateGeometryIntent(oCenterMark(1))

Dim genDim As GeneralDimension
genDim = oSheet.DrawingDimensions.GeneralDimensions.AddLinear(intent1, intent2, DimensionTypeEnum.kAlignedDimensionType)

oCenterMark(0).Visible = False
oCenterMark(1).Visible = False
oCenterMark(2).Visible = False
oCenterMark(3).Visible = False
oCenterMark(4).Visible = False

 

0 Likes
Message 3 of 3

adam.nagy
Autodesk Support
Autodesk Support

Hi,

 

The error I get when running your code is this:

Error in rule: Rule0, in document: iLogicTest.dwg

Unable to cast COM object of type 'System.__ComObject' to interface type 'Inventor.Point2d'. 
This operation failed because the QueryInterface call on the COM component for the interface with 
IID '{CB69F173-558E-11D3-B793-0060B0F159EF}' failed due to the following error: 
No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).

It's because the first parameter of the AddLinear should be the position of the text, a Point2d object.

 

You'd need to do something like this:

pt = ThisApplication.TransientGeometry.CreatePoint2d() 
genDim = oSheet.DrawingDimensions.GeneralDimensions.AddLinear(pt, intent1, intent2, DimensionTypeEnum.kAlignedDimensionType)

Cheers,



Adam Nagy
Autodesk Platform Services