Autodesk Inventor Customization
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Re: Retrieve dimensions
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Guys,
What if I have 3 views and I need to dimension OAL length on the front view, OAL width on the side view, and lets say a hole on the top view. How to modify the code. I tried to play with it, copiyng the part of the code and changing the view name, but it gives me an error.
Thanks in advance.
Re: Retrieve dimensions
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hi,
Here you have some code that can do that, only thing what you must have do is give the Drawing View a name and give the user / model parameter the right name.
Sub Main
Dim oDrawDoc As DrawingDocument = ThisDoc.Document
Dim oSheet As Sheet = oDrawDoc.ActiveSheet
RetrieveDimByView(oSheet, "FrontView", "RetD_")
RetrieveDimByView(oSheet, "RightView", "RetDRight_")
RetrieveDimByView(oSheet, "TopView", "RetDTop_")
End Sub
Sub RetrieveDimByView(ByVal oSheet As Sheet, ByVal ViewName As String, ByVal PrefixStr As String)
Dim oDrawView As DrawingView
For Each oDrawView In oSheet.DrawingViews
If oDrawView.Name = ViewName Then
Exit For
End If
Next
Dim oGeneralDimensionsEnum As GeneralDimensionsEnumerator
oGeneralDimensionsEnum = oSheet.DrawingDimensions.GeneralDimensions.Retrieve(oDrawView)
Dim oGeneralDimension As GeneralDimension
For Each oGeneralDimension In oGeneralDimensionsEnum
Dim oParameter As Parameter
Try
oParameter = oGeneralDimension.RetrievedFrom.Parameter
Catch
' Error to set oParameter.
' Go further to delete the dimension.
End Try
If oParameter.DrivenBy.count <> 0 Then
Dim oDrivenByParameter As Parameter
For Each oDrivenByParameter In oParameter.DrivenBy
If InStr(oDrivenByParameter.Name, PrefixStr) = 0 Then
oGeneralDimension.Delete
End If
Next
Else
If InStr(oParameter.Name, PrefixStr) = 0 Then
oGeneralDimension.Delete
End If
End If
Next
oSheet = Nothing
End Sub
Programmer Engineering
inventor professional 2011 / 2012 / 2013
Re: Retrieve dimensions
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Excellent works just great.
One more question, is there any chance to offset the dimensions?
Thanks,
Re: Retrieve dimensions
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hi Marco,
It works fine, but my model is based on a multi body part.
So if i retrieve the dimensions, i get the dimensions from every part from my assembly.
in the standard interface, i can select a part thats part of the view, how can i do this thru the api?
the API help tells me that you can use a "demensionToRetrive":
Sub Retrieve(ViewOrSketch As IDispatch, ByRef DimensionsToRetrieve As [optional] VARIANT, Result As [out, retval] GeneralDimensionsEnumerator*)
I've tried some to create a ObjectCollection with the specific part, but i doesn't seem to work. Do you have any suggestion.
Kind regards,
Theo
Re: Retrieve dimensions
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hello achmidt,
What you can do is select all dimension and then arrange dimensions.
Start code"
Dim oCommandMgr As CommandManager = _
ThisApplication.CommandManager
oCommandMgr.ControlDefinitions.item("DrawingSelect
oCommandMgr.ControlDefinitions.item("DrawingArrang
"End code
Best regards,
Programmer Engineering
inventor professional 2011 / 2012 / 2013
Re: Retrieve dimensions
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hello Theo,
If you want to make a collection of a Part you can do something like this,
Dim oAssemblyDocument As Inventor.AssemblyDocument = _ oDrawView.ReferencedDocumentDescriptor.ReferencedDocument Dim oOcc As Inventor.ComponentOccurrence = _ oAssemblyDocument.ComponentDefinition.occurrences. item(1) Dim oGeneralDimensionsObj As ObjectCollection = _ oSheet.DrawingDimensions.GeneralDimensions.GetRetr ievableDimensions(oDrawView, oOcc)
The oGeneralDimensionsObj has now the retrieved dimensions form the first Part.
Best regards,
Programmer Engineering
inventor professional 2011 / 2012 / 2013
Re: Retrieve dimensions
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Thanks!!!
Re: Retrieve dimensions
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
I`d like to share the code I assembled from different pieces (see attached). Configurator works great but I have few problems with the drawing dimensions.
I`m not sure how to place flat pattern OAL dim`s, can`t place bend dim`s, not sure how to modify flat pattern placement code so it shows bend extents.
oView4 = oSheet.DrawingViews.AddBaseView(oPartDoc,oPoint4, ViewScale,kDefaultViewOrientation, kHiddenLineDrawingViewStyle,,, oBaseViewOptions)
Also I`m not sure how to do ordinate dim`s for the holes (horizontal & vertical).
If you`d like to test it out don`t forget to change the template path and name in the code.
I have an external rule that I run after drawing creation (see below), it places the dimensions I need.
Sub Main
Dim oDrawDoc As DrawingDocument = ThisDoc.Document
Dim oSheet As Sheet = oDrawDoc.ActiveSheet
RetrieveDimByView(oSheet, "VIEW1", "Fr_") ' front view
RetrieveDimByView(oSheet, "VIEW3", "Rs_") ' right side view
RetrieveDimByView(oSheet, "VIEW2", "Tv_") ' top view
'RetrieveDimByView(oSheet, "View3", "RetDTop_")
End Sub
Sub RetrieveDimByView(ByVal oSheet As Sheet, ByVal ViewName As String, ByVal PrefixStr As String)
Dim oDrawView As DrawingView
For Each oDrawView In oSheet.DrawingViews
If oDrawView.Name = ViewName Then
Exit For
End If
Next
Dim oGeneralDimensionsEnum As GeneralDimensionsEnumerator
oGeneralDimensionsEnum = oSheet.DrawingDimensions.GeneralDimensions.Retriev e(oDrawView)
Dim oGeneralDimension As GeneralDimension
For Each oGeneralDimension In oGeneralDimensionsEnum
Dim oParameter As Parameter
Try
oParameter = oGeneralDimension.RetrievedFrom.Parameter
Catch
' Error to set oParameter.
' Go further to delete the dimension.
End Try
If oParameter.DrivenBy.count <> 0 Then
Dim oDrivenByParameter As Parameter
For Each oDrivenByParameter In oParameter.DrivenBy
If InStr(oDrivenByParameter.Name, PrefixStr) = 0 Then
oGeneralDimension.Delete
End If
Next
Else
If InStr(oParameter.Name, PrefixStr) = 0 Then
oGeneralDimension.Delete
End If
End If
Next
oSheet = Nothing
Dim oCommandMgr As CommandManager = _
ThisApplication.CommandManager
oCommandMgr.ControlDefinitions.item("DrawingSelect AllInventorDimsCmd").Execute
oCommandMgr.ControlDefinitions.item("DrawingArrang eDimensionsCmd").Execute
End SubWould be great to add a code that automatically scales up/down the views and places them on the sheet.
Any help appreciated. Thanks,



