Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
WCrihfield
in reply to: b.kushaiynov

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

EESignature

(Not an Autodesk Employee)