Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Finding all sketches defined by a plane

5 REPLIES 5
Reply
Message 1 of 6
robertpugh8785
459 Views, 5 Replies

Finding all sketches defined by a plane

Hello.  I'm wondering if anyone knows of or can write a VBA routine that will allow you to select a work plane in the browser and find all sketches that are defined by it.  We do extensive skeletal modelling and our master parts consist of many sketches and sketch planes

 

Note, I am aware of the VBA routine that allows you to select a sketch and highlight the plane or surface that it is made off of.

 

Thanks all...

5 REPLIES 5
Message 2 of 6
pcrawley
in reply to: robertpugh8785

Well, I know this isn't the answer you are looking for, but a dirty solution would be to delete the Workplane in question.  You'll be prompted to delete dependent sketches - and they'll all highlight in the browser.  Cancel or Undo could quickly become your new best friends!

Peter
Message 3 of 6
torbjorn
in reply to: robertpugh8785

I know exactly what you want - I miss it myself. Unfortunately I cannot help you - but I was very interested in the code you already have found.

 

Could you please point me in the direction where I can find the VBA to select a sketch and find its  sketchplane ? 

Tags (1)
Message 4 of 6
robertpugh8785
in reply to: pcrawley

Hmmm... actually this will probably work just fine (and I should have thought of this myself).

 

Thanks for the reminder...

Message 5 of 6
robertpugh8785
in reply to: torbjorn

Message 6 of 6
torbjorn
in reply to: robertpugh8785

Thanks a lot - the code works as a charm 🙂

 

Used that code as a basis and made a routine that does what you initially wanted -  finding all sketches defined by a selected plane:

 

Public Sub FindSketchesOnPlane()
Dim ODoc As Document
Set ODoc = ThisApplication.ActiveDocument

'Check to make sure a single plane is selected.
If ODoc.SelectSet.Count > 0 Then
If (ODoc.SelectSet.Item(1).Type <> kWorkPlaneObject) Then
MsgBox "A Workplane must be selected first."
Exit Sub
End If
Else
MsgBox "A Workplane must be selected first."
Exit Sub
End If

Dim wPlane As WorkPlane
Dim SMessage As String
SMessage = ""
Set wPlane = ODoc.SelectSet.Item(1)

Dim oSketch As PlanarSketch

For Each oSketch In ODoc.ComponentDefinition.Sketches

If Not (oSketch.PlanarEntity Is Nothing) Then
If oSketch.PlanarEntity.Type = kWorkPlaneObject Then
If (oSketch.PlanarEntity.Name = wPlane.Name) Then
'found a sketch using selected plane as sketch plane
Debug.Print "FOUND: " & oSketch.Name
SMessage = SMessage & oSketch.Name & Chr$(13)
ODoc.SelectSet.Select oSketch
End If
End If
End If
Next
If SMessage <> "" Then
MsgBox SMessage, , "Skeches"
Else
MsgBox "The Work plane is not used as sketch plane", , "Sketches"
End If
End Sub

 

Tags (1)

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report