Autodesk Inventor Customization
- Start Article
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Retrieve dimensions
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hi,
I want to retrieve dimensions in a drawing with ilogic. I found some code in de api help, but i can't figure out how to translate it into a ilogic code.
I always use assembly models in these drawing and all the parameters have unique names. So in my drawing i want to retrieve some specific dimensions in a view.
Can anyone point me in the right direction? maybe a small sample?
kind regards,
theo
Solved! Go to Solution.
Re: Retrieve dimensions
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hello Theo,
Here you have a little example how-to retrieve dimensions with a special parameter name in iLogic.
The workflow I use is:
1. Retrieve all dimensions.
2. Iterate through the dimensions.
3. Delete dimensions if not a special parameter.
The special parameter name has a prefix “RetD_” as model / userparameter.
Start code”
Dim oDrawDoc As DrawingDocument = ThisDoc.Document
Dim oSheet As Sheet = oDrawDoc.ActiveSheet
Dim oDrawView As DrawingView = oSheet.DrawingViews(1)
Dim oGeneralDimensionsEnum As GeneralDimensionsEnumerator
oGeneralDimensionsEnum = oSheet.DrawingDimensions.GeneralDimensions.Retriev
Dim PrefixStr As String = "RetD_"
Dim oGeneralDimension As GeneralDimension
For Each oGeneralDimension In oGeneralDimensionsEnum
Dim oParameter As Parameter
oParameter = oGeneralDimension.RetrievedFrom.Parameter
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
“End Code
I hoop it was use full.
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
Wow!!! That is the great code!!!!
Thank you so much!!!
Re: Retrieve dimensions
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
![]()
Marco,
Thanks, it works great!!
Houdoe,![]()
gr Theo
Re: Retrieve dimensions
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
hi
will this rule delete dimensions by hole features?
it seems not going to work at that way.
thanks.
Re: Retrieve dimensions
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
I'd suggest you provide a dataset to recreate the problem you met with. This will help the peers here to diagnose.
Xiaodong Liang
Developer Technical Services
Autodesk Developer Network
Re: Retrieve dimensions
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
HI,
please check attachment. there will be an error when run ilogic rule.
the dimension by hole feature is not going to work.
it is 1/4--20 hole. the diameter of tap drill hole casues the error.
thanks a lot.
Re: Retrieve dimensions
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hi,
You were right the code stopped working because the Tapped Hole has no RetrievedFrom.Parameter.
Here you have the modified code.
Start code”
Dim oDrawDoc As DrawingDocument = ThisDoc.Document Dim oSheet As Sheet = oDrawDoc.ActiveSheet Dim oDrawView As DrawingView = oSheet.DrawingViews(1) 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, "RetD_") = 0 Then oGeneralDimension.Delete End If Next Else oGeneralDimension.Delete End If Next
“End Code
I didn’t test it with your Part because I have now only version 2011.
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
hi,
at the near end of your code, you miss some parts. it should be like this,
If InStr(oParameter.Name, "test_") = 0 Then
oGeneralDimension.Delete
End If
otherwise, the code will delete all dimensions.
thanks for your information.
Re: Retrieve dimensions
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hi,
Something like this:
Dim oDrawDoc As DrawingDocument = ThisDoc.Document Dim oSheet As Sheet = oDrawDoc.ActiveSheet Dim oDrawView As DrawingView = oSheet.DrawingViews(1) Dim oGeneralDimensionsEnum As GeneralDimensionsEnumerator oGeneralDimensionsEnum = oSheet.DrawingDimensions.GeneralDimensions.Retrieve(oDrawView) Dim PrefixStr As String = "RetD_" 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
Programmer Engineering
inventor professional 2011 / 2012 / 2013


