- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Unable to create dimension for flat pattern component(sheet metal) diameter with the help of attribute helper
here is the code which i can able to generate dimension for part document when comes to flat pattern it is failing.
Public Function AHDim(docType As String,viewName As String ,dimType As String, intend As String, Layer As String,DimCondition As String, XYval As String) As Boolean Dim oDrawDoc As DrawingDocument oDrawDoc = ThisApplication.ActiveDocument Dim oSheet As Sheet oSheet = oDrawDoc.ActiveSheet Dim oView,oView2 As DrawingView oView = ActiveSheet.View(viewName).View Dim oRefDoc As PartDocument = oView.ReferencedDocumentDescriptor.ReferencedDocument Dim oTG As TransientGeometry oTG = ThisApplication.TransientGeometry Dim oObjs As ObjectCollection Dim aoEdges As Edge oObjs = oRefDoc.AttributeManager.FindObjects("iLogicEntityNameSet", "iLogicEntityName", intend ) aoEdges = oObjs.Item(1) Dim aoDrawCurves As DrawingCurve oDrawViewCurves = oView.DrawingCurves(aoEdges) aoDrawCurves = oDrawViewCurves.Item(1) Dim XYSplitVal As String() XYSplitVal = XYval.Split(",") Dim Xval, Yval As Double Xval = CType(XYSplitVal(0), Double) Yval = CType(XYSplitVal(1), Double) Dim viewCenter As Point2d =oView.Center Dim oTextPosition As Point2d = oTG.CreatePoint2d(viewCenter.X+Xval, viewCenter.Y+Yval) Dim oGeneralDims As GeneralDimensions oGeneralDims = oSheet.DrawingDimensions.GeneralDimensions Dim oDim As GeneralDimension Select Case dimType Case "RadI" oDim = oGeneralDims.AddRadius(oTextPosition, oSheet.CreateGeometryIntent(aoDrawCurves), True, False, , , oDrawDoc.StylesManager.Layers.Item(Layer)) Case "RadO" oDim = oGeneralDims.AddRadius(oTextPosition, oSheet.CreateGeometryIntent(aoDrawCurves), False, False, , , oDrawDoc.StylesManager.Layers.Item(Layer)) Case "Dia" oDim = oGeneralDims.AddDiameter(oTextPosition, oSheet.CreateGeometryIntent(aoDrawCurves), True, False, , ,oDrawDoc.StylesManager.Layers.Item(Layer)) End Select If DimCondition = "1" Then oDim.Tolerance.SetToBasic() ElseIf DimCondition = "2" Then oDim.Tolerance.SetToReference() End If End Function
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi @khadeerkruthi. Does it show an error dialog when it fails, or does it just not seem to do anything? If it is showing an error dialog, then can you please include what the second tab of that error dialog says here, one way or another, so we can look at it. Sometimes that will give us a clue as to where within the code the problem is occurring. Are you sure that is it returning the named object within the ObjectCollection it gets from the AttributeManager.FindObjects method? Are you sure it is finding a DrawingCurve of that object within the DrawingView? Maybe the Sheet.CreateGeometryIntent method needs the second, optional input to be specified. I can not be sure at this point. You could try inserting more code at those first two points to check if the ObjectCollection.Count = 0, and if so, provide some sort of feedback like a Logger.Debug() type line. Or maybe enclosing some of the lines of code within the Try side of Try...Catch statements, then provide some feedback on the Catch side to help indicate where it may be encountering problems.
Wesley Crihfield
(Not an Autodesk Employee)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
when i run the ilogic for flatpattern view i get this message: Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))
this line it is failing
oDrawViewCurves = oView.DrawingCurves(aoEdges)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi @khadeerkruthi. The first (left) tab of the error message is generally not that useful, but the second tab (on the right, usually labeled "More Info") of the error message will sometimes contain something useful, which will help indicate where it is encountering the error. If the error is happening at the line you specified, then there are still multiple possible reasons for that. Either the variable "oDrawViewCurves" may already have a value set to it from the previous run, which would cause problems, or the "aoEdges" variable may not be set to a value, because it may have not found that named object. Here is some example iLogic code that you may be able to use that might help some.
Replace this line of code:
oDrawViewCurves = oView.DrawingCurves(aoEdges)
...with this block of code:
If aoEdges Is Nothing Then Return False 'or Exit Function
Dim oDrawViewCurves As DrawingCurvesEnumerator = Nothing
Try 'try doing something that might fail
oDrawViewCurves = oView.DrawingCurves(aoEdges)
Catch 'what to do when that fails
Return False 'or Exit Function
'Logger.Error("Error getting drawing view curves.")
End Try
If oDrawViewCurves Is Nothing OrElse oDrawViewCurves.Count = 0 Then
Return False 'or Exit Function
End If
Since I do not know what the purpose of the Boolean type return value of the main Function is, you could use 'Exit Function' instead of 'Return False' in those 3 places, but both ways will likely have the same effect (exiting the Function at that point, and the returned Boolean will likely be False).
Wesley Crihfield
(Not an Autodesk Employee)