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.
Solved by marco_suurlant. Go to Solution.
Hi Macro Surlant
The code will not work in some partlicular condition, where the inside "For ...Loop execute for another time in a complex model.
But it will work for the simpler model. But due the necessity I tried my level best and found out the solution for that.
I hope this code would be generic but still I expect few of the our community member to give the assuarance on that.
Thank you. Following is the altered code. This code is written in VB.Net kindly modify based on your programming language
Regards
Prasad
' Set a reference to the active drawing document
Dim oDrawDoc As Inventor.DrawingDocument
Dim oSheet As Inventor.Sheet
Dim oDrawView As Inventor.DrawingView
Dim oGeneralDimensionsEnum As Inventor.GeneralDimensionsEnumerator
Dim oGeneralDimension As Inventor.GeneralDimension
oDrawDoc = inventorApp.ActiveDocument
oSheet = oDrawDoc.ActiveSheet
oDrawView = oSheet.DrawingViews(1)
oGeneralDimensionsEnum = oSheet.DrawingDimensions.GeneralDimensions.Retrieve(oDrawView)
Dim PrefixStr AsString = "RetD_"
ForEach oGeneralDimension InoGeneralDimensionsEnum
Dim oParameter As Inventor.Parameter
oParameter = oGeneralDimension.RetrievedFrom.Parameter
If oParameter.DrivenBy.Count <> 0 Then
Dim oDrivenByParameter As Inventor.Parameter
'''This Loop needed Special care - Prasad
ForEach oDrivenByParameter InoParameter.DrivenBy
If InStr(oDrivenByParameter.Name, PrefixStr) = 0 Then
oGeneralDimension.Delete()
EndIf
Exit For ''(This is the extra line needed)- Prasad
Next
Else
If InStr(oParameter.Name, PrefixStr) = 0 Then
oGeneralDimension.Delete()
EndIf
EndIf
Next
I'm sorry for re-opening this post. First of all thanks for your code, it's really helpfull for me. But I'd like to change it a little bit and I was wondering if you could help me out.
The thing is that I'd like the workflow to be diferent. Instead of retrieving them all and then erase unwanted, I need to retrieve just the named dimensions.
The problem I'm experiencing is that when I use the rule on big assemblies, even if i just want to retrieve a couple o dim's, it takes too much time 'cause it's retrieving all the dimensions in there and then erasing.
I guess retrieving only the named dim's would help get things faster, is that right?
Here I post the code I'm using... which is basically your code 🙂
Thanks in advance
SyntaxEditor Code Snippet
oDrawView = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingViewFilter , "SELECCIONA UNA VISTA") Dim PrefixStr As String = InputBox("PREFIJO DE COTAS A OBTENER.............(Dejar en blanco para obtener todas o escribir p para obtener las generadas con iLogic)", "RECUPERADOR DE COTAS", "p") Dim oDrawDoc As DrawingDocument = ThisDoc.Document Dim oSheet As Sheet = oDrawDoc.ActiveSheet Dim oGeneralDimensionsEnum As GeneralDimensionsEnumerator oGeneralDimensionsEnum = oSheet.DrawingDimensions.GeneralDimensions.Retrieve(oDrawView) 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