- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi everyone,
I'm trying to create a drawing dimension between two work points but Inventor crashes right away. The code is actually very simple and I used one of the Brian Ekins' documents as a reference https://forums.autodesk.com/autodesk/attachments/autodesk/120/58687/1/MA316-5,ConfiguratorTips.pdf
It's a Part Drawing and I created center marks from the work points before adding the dimension. I didn't create Work Point proxies since I'm not working with a work point from a part referenced in an assembly.
If I disabled the last line Inventor doesn't crash but if I enabled it, Inventor crashes right away. I'd appreciate any idea/help. Thanks!
This is an iLogic code using API objects.
Here is the code
SyntaxEditor Code Snippet
'Get the Sheets collection oSheets=ThisApplication.ActiveDocument.Sheets 'Get the first sheet oSheet=oSheets.Item(1) 'Get the drawing views collection oDrawingViews=oSheets.Item(1).DrawingViews 'Get the first drawing view (Actually there is only one view) Dim oView As DrawingView oView=oDrawingViews.Item(1) 'Get the referenced document - Part file oPartDoc = oView.ReferencedDocumentDescriptor.ReferencedDocument oWorkPoints=oPartDoc.ComponentDefinition.WorkPoints
'Item 1 is the origin and item 2 is the first user work point oWP1 = oWorkPoints.Item(2) 'First User WP oWP2 = oWorkPoints.Item(3) 'Second User WP 'Create centermarks based on the Work Points oCMark1 = oSheet.Centermarks.AddByWorkFeature(oWP1, oView) oCMark2 = oSheet.Centermarks.AddByWorkFeature(oWP2, oView) ' Create geometry intents for the center marks oIntent1 = oSheet.CreateGeometryIntent(oCMark1) oIntent2 = oSheet.CreateGeometryIntent(oCMark2) 'Add a dimension. oGeneralDims = oSheet.DrawingDimensions.GeneralDimensions 'kVerticalDimensionType 60163 Dimension type Is vertical. DimType = kVerticalDimensionType 'Create a point for the text oTG = ThisApplication.TransientGeometry oTextPos = oTG.CreatePoint2d(20, 18) oLinearDim = oGeneralDims.AddLinear(oTextPos, oIntent1, oIntent2, DimType)
Solved! Go to Solution.