Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
This works as expected when i have just a part file open but when it's a child that is the activeedit within an assembly it does not select the workplane of the child.
I have tried activedocument.selectset and activeobject.selectset but neither works. I dont think im understanding which object currently controls the select set in this instance.
Public Sub CreateSketch() 'Get a hook to the application. Dim invApp As Inventor.Application: Set invApp = ThisApplication 'Get the object currently being edited. Dim ActiveObject As Object: Set ActiveObject = ThisApplication.ActiveEditObject 'Determine if a the object being edited is a document If Not TypeOf ActiveObject Is PartDocument Then Exit Sub Else Dim odoc As Inventor.PartDocument: Set odoc = ActiveObject End If 'Check for features. If there are any features the exit from the sub. If odoc.ComponentDefinition.Features.Count > 0 Then Exit Sub 'Lookat XY Plane Dim oWP As WorkPlane: Set oWP = odoc.ComponentDefinition.WorkPlanes("XY Plane") odoc.SelectSet.Clear odoc.SelectSet.Select oWP invApp.CommandManager.ControlDefinitions.Item("AppLookAtCmd").Execute odoc.SelectSet.Clear 'Create a sketch on XY, name it and make it ready for use. Dim oSketch As PlanarSketch: Set oSketch = odoc.ComponentDefinition.Sketches.Add(odoc.ComponentDefinition.WorkPlanes("XY Plane"), False) 'oSketch.Name = "Sketch" & CStr(oDoc.ComponentDefinition.Sketches.Count) oSketch.Edit 'Project the origin centre point. Even having the App Options set will not create it. Dim oOriginSketchPoint As SketchPoint: Set oOriginSketchPoint = oSketch.AddByProjectingEntity(odoc.ComponentDefinition.WorkPoints("Center Point")) 'Activate the model browser. odoc.BrowserPanes("Model").Activate End Sub
Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.
---------------------------------------------------------------------------------------------------------------------------
Inventor 2010 Certified Professional
Currently using 2023 Pro
Solved! Go to Solution.