offset by distance in drawing sketch

offset by distance in drawing sketch

Vincent_Campas
Enthusiast Enthusiast
582 Views
3 Replies
Message 1 of 4

offset by distance in drawing sketch

Vincent_Campas
Enthusiast
Enthusiast

This is always giving me a parameter incorrect error.

I tried adding different things to the collection (sketchlines, sketchentities, ...SketchLines.item(1), ....) 

But always the parameter incorrect.

Sub main()
	Dim oDrawingDocument As DrawingDocument = ThisDoc.Document
	Dim oSheet As Sheet = oDrawingDocument.ActiveSheet
	Dim oView As DrawingView = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingViewFilter, "Pick view where the sections shoud be made")
	If oView Is Nothing Then Exit Sub
	Dim ClArray As New ArrayList
	KeepAdding:
	Dim oSelectCenterline As Centerline = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingCenterlineFilter, "Pick the centerlines where a section shoud be made")
	If Not oSelectCenterline Is Nothing Then
		ClArray.Add(oSelectCenterline)
		GoTo KeepAdding
	End If


	For Each oCenterLine As Centerline In ClArray
		Dim oSketch As DrawingSketch
		Dim oObjCol As ObjectCollection
		oObjCol = ThisApplication.TransientObjects.CreateObjectCollection
		
		oSketch = oView.Sketches.Add
		Dim oSketchEntity As SketchEntity = oSketch.AddByProjectingEntity(oCenterLine)
		oObjCol.Add(oSketchEntity)
		oSketch.OffsetSketchEntitiesUsingDistance(oObjCol, 150, True, False, False)
		
		'Create section on this sketch
		'oSheet.DrawingViews.AddSectionView(oView, oSketch, oPoint, DrawingViewStyleEnum.kFromBaseDrawingViewStyle, 1 / 100, True, oLabelName, , False, 300)

	Next 

End Sub

 

0 Likes
Accepted solutions (2)
583 Views
3 Replies
Replies (3)
Message 2 of 4

Ralf_Krieg
Advisor
Advisor
Accepted solution

Hello

 

Try to enter sketch edit mode before projecting and offset. By the way oPoint is not defined, the next point of failure. 😉

Set oPoint to 0,0 just for test it worked.

Sub main()
	Dim oDrawingDocument As DrawingDocument = ThisDoc.Document
	Dim oSheet As Sheet = oDrawingDocument.ActiveSheet
	Dim oView As DrawingView = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingViewFilter, "Pick view where the sections shoud be made")
	If oView Is Nothing Then Exit Sub
	Dim ClArray As New ArrayList
	KeepAdding:
	Dim oSelectCenterline As Centerline = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingCenterlineFilter, "Pick the centerlines where a section shoud be made")
	If Not oSelectCenterline Is Nothing Then
		ClArray.Add(oSelectCenterline)
		GoTo KeepAdding
	End If


	For Each oCenterLine As Centerline In ClArray
		Dim oSketch As DrawingSketch
		Dim oObjCol As ObjectCollection
		oObjCol = ThisApplication.TransientObjects.CreateObjectCollection
		
		oSketch = oView.Sketches.Add
		
		oSketch.Edit 
		Dim oSketchEntity As SketchEntity = oSketch.AddByProjectingEntity(oCenterLine)
		oObjCol.Add(oSketchEntity)
		oSketch.OffsetSketchEntitiesUsingDistance(oObjCol, 1.5, True, False, False)
		
		oSketch.ExitEdit
		
		Dim oPoint As Inventor.Point2d = ThisApplication.TransientGeometry.CreatePoint2d(0, 0)
		
		'Create section on this sketch
		oSheet.DrawingViews.AddSectionView(oView, oSketch, oPoint, DrawingViewStyleEnum.kFromBaseDrawingViewStyle, 1 / 100, True, oLabelName, , False, 300)

	Next 

End Sub

 

 


R. Krieg
RKW Solutions
www.rkw-solutions.com
0 Likes
Message 3 of 4

Vincent_Campas
Enthusiast
Enthusiast
Thanks! 

Do you need to edit every sketch before you do something with it?
Because the project geometry worked withouth editing, but the offset didn't.

Yeah oPoint and olabelName weren't declared yet, Wasn't ready for that part yet.
0 Likes
Message 4 of 4

Ralf_Krieg
Advisor
Advisor
Accepted solution

Hello

 

Some operations can be done without entering edit mode. I never found a list which. I always try without and if it fails second try with edit mode. ^^

 


R. Krieg
RKW Solutions
www.rkw-solutions.com
0 Likes