08-29-2023
07:46 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
08-29-2023
07:46 AM
Hi @b.kushaiynov. Even though this task seems simple, it is a bit more complicated to get working than it seems. It is fairly easy to create the sketch, and project the geometry, but creating the offset geometry is the tricky part. Below is some iLogic code to get you started. But it was throwing an error in my brief testing for some reason at the line of code which calls the main method (OffsetSketchEntitiesUsingDistance).
Sub Main
If ThisDoc.Document.DocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then Exit Sub
Dim oView As DrawingView = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingViewFilter, "Select View")
If oView Is Nothing Then Exit Sub
Dim oDDoc As DrawingDocument = oView.Parent.Parent
Dim oTrans = ThisApplication.TransactionManager.StartTransaction(oDDoc, "View Sketch")
Dim oDCurves As DrawingCurvesEnumerator = oView.DrawingCurves
Logger.Info("oDCurves.Count = " & oDCurves.Count)
If oDCurves Is Nothing OrElse oDCurves.Count = 0 Then Exit Sub
Dim oDSketch As DrawingSketch = oView.Sketches.Add
Dim oSEsColl As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
For Each oDCurve As DrawingCurve In oDCurves
Dim oPSE As SketchEntity = oDSketch.AddByProjectingEntity(oDCurve)
'Logger.Info("TypeName(oPSE) = " & TypeName(oPSE))
oSEsColl.Add(oPSE)
Next 'oDCurve
Logger.Info("oSEsColl.Count = " & oSEsColl.Count)
Dim oSEE As SketchEntitiesEnumerator = Nothing
Try
oSEE = oDSketch.OffsetSketchEntitiesUsingDistance(oSEsColl, 5, True)
oTrans.End
Catch e As Exception
Logger.Error(e.Message & vbCrLf & e.StackTrace)
oTrans.Abort
End Try
End Sub
Wesley Crihfield
(Not an Autodesk Employee)