Deleting centerlines on a drawing

Deleting centerlines on a drawing

DWhiteley
Advisor Advisor
805 Views
2 Replies
Message 1 of 3

Deleting centerlines on a drawing

DWhiteley
Advisor
Advisor

I've got this bit of code that is supposed to delete all centerlines on my drawing sheet.

 

j = oSheet.Centerlines.Count

For i = 1 To j

Try

oSheet.Centerlines.Item(i).Delete()

Catch ex As Exception

End Try

Next

 

Howver, I find that (inellegantly) I have to run it a few times in my code to actually remove all centerlines.

For some reason I get exceptions on some. It's not as though they have child/parent relationships - they are just workplanes displayed on the drawing.

 

The workplanes were created using this code:

 

j = oPartCompDef.WorkPlanes.Count

For i = 4 To j

oWP = oPartCompDef.WorkPlanes.Item(i)

Dim oWPpx As WorkPlaneProxy

Call oOcc.CreateGeometryProxy(oWP, oWPpx)

Call oDrawingDoc.Sheets(1).DrawingViews(1).SetVisibility(oWPpx, True)

 

Next

 

Does anyone have any ideas on why this is happening?

 

Thanks in adavance

 

Dave

envisage uk

0 Likes
806 Views
2 Replies
Replies (2)
Message 2 of 3

MechMachineMan
Advisor
Advisor

See if this works any better for you

 

Sub Main()
Dim oDoc As Document = ThisApplication.ActiveDocument
Dim oSheet As Sheet
Dim oCL As Centerline


For Each oSheet in oDoc.Sheets
	oSheet.Activate

	For Each oCL in oSheet.Centerlines
		'If oCL.Attached = False
			oCL.Delete
		'End if 'Centerline attached
	Next 'Centerline

End Sub

--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
Message 3 of 3

DWhiteley
Advisor
Advisor

many thanks, i'll give it a try

0 Likes