- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello Everyone, Greetings 🙂
I have created an iLogic code for my part which automatically created dimension when a rule is run for diemnsions creation using iLogic.
I have Inventor 2019 so I am using "Assign Name" functionality (similar to attribute manager add-in but much simpler) to create these dimensions.
Now each time the part is updated the dimension will be created between the two faces of the part, which is what I want.
Now I also want to delete the previously created iLogic dimensions because after each update o the part, previous dimension is staying their and new dimension is being added over it which obliviously i dont want.
I found this code in search of my answer but when I run this code, nothing happens whatsoever, not even an error is returned. So can someone please help me understand what is it I should do accomplish what I want?
Doc = ThisApplication.ActiveDocument Dim Sheet As Inventor.Sheet oSheet = Doc.ActiveSheet 'Iterate over all diemnsions Dim oDim As GeneralDimension For Each oDim In oSheet.DrawingDimensions If oDim.AttributeSets.NameIsUsed("iLogic_Created") = True Then oDim.Delete End If Next Dim oDoc As Inventor.Document oDoc = ThisApplication.ActiveDocument
Here is the code I am using to generate dimensions for the part, which is working as it should, in case someone needs it 🙂
Dim partDoc As PartDocument = ThisDoc.ModelDocument 'assinging variablr to active part documemnt Dim namedEntities = iLogicVb.Automation.GetNamedEntities(partDoc) 'calling in all named faces in the active part doc face0 = namedEntities.FindEntity("J_Face") 'assign named faces face1 = namedEntities.FindEntity("J_end") Dim oSheet = ThisApplication.ActiveDocument.ActiveSheet 'Assigning Variable to active sheet Dim oView As DrawingView = ActiveSheet.View("VIEW1").View 'assign variable to active sheet 'Dim curve0 As DrawingCurvesEnumerator 'no idea why curve0 = oView.DrawingCurves(face0) 'assign faces to variable as drawing curves curve1 = oView.DrawingCurves(face1) Dim finalCurve As DrawingCurve 'assigning a variable as drawing curve to store faces values Dim finalCurve1 As DrawingCurve 'MessageBox.Show(curve1.Count.ToString) finalCurve = curve0.Item(1) 'assigning curve faces values to variables finalCurve1 = curve1.Item(1) 'MessageBox.Show(finalCurve1.ToString) Dim oGeomIntent1 As GeometryIntent 'assigning a variable to geometry intent to use as annotations Dim oGeomIntent2 As GeometryIntent Dim oGeneralDims As GeneralDimensions = oSheet.DrawingDimensions.GeneralDimensions ' gaining acces to dimensioning in sheet 'oGeomIntent1 = oSheet.CreateGeometryIntent(finalCurve) 'oGeomIntent2 = oSheet.CreateGeometryIntent(finalCurve.EndPoint) oGeomIntent1 = oSheet.CreateGeometryIntent(finalCurve) ' assigning drawing curve values to geometry variable oGeomIntent2 = oSheet.CreateGeometryIntent(finalCurve1) Dim textPoint1 As Inventor.Point2d = ThisApplication.TransientGeometry.CreatePoint2d(oView.Center.X - 6.5 , oView.Top) 'Dim textPoint2 As Inventor.Point2d = ThisApplication.TransientGeometry.CreatePoint2d(oView.Center.X, oView.Top + .10) oDim = oGeneralDims.AddLinear(textPoint1, oGeomIntent1, oGeomIntent2) 'oDim = oGeneralDims.AddLinear(textPoint2, oGeomIntent2) 'Dim linDim1 = genDims.AddLinear("Dimension 1", VIEW1.SheetPoint(0.5, -0.1),face1,Face2) Comapring code
Solved! Go to Solution.