- 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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi Rob,
thanks for your help! However this doesn't fix the issue. I've tried different inputs for the dimension type/style (your suggestion too) and it crashes anyways. In fact, the dim type/style is not mandatory in the syntax. I actually deleted the dim type and it crashes too.
I'd appreciate it if you or someone else has more ideas.
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
There is two problems in the code.
You have to change both the following rows to get it to work..
Dim oGeneralDims as GeneralDimensions = oSheet.DrawingDimensions.GeneralDimensions DimType = DimensionTypeEnum.kVerticalDimensionType
Regards
Rikard
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Thanks! It worked!
But I'm still wondering why did I need to declare the General Dimensions (Dim GeneralDims As General Dimensions)? We don't need to declare objects in iLogic (for instance, you'll see my code doesn't have oSheets, oSheet, oDrawingViews declared).
Second, the DimType is optional rather than mandatory.
Although it worked very well, i'd appreciate it if you can explain to me both solutions (General Dimensions and DimType)
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I can't explain it.
I don't trust automatic declarations. So I declare ever variable ever time.
ILogic has problems with enums so just to be safe I always write it with enum-types. I think it works with the number but I don't think it looks nice.
Maybe someone at Autodesk can explain this.
/Rikard