- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have been researching this a lot and I'm getting closer and closer and I think I'm down to the last little bit but I need some help as I am just learning how to program so I am having trouble putting this together. I have a drawing with a view and in that view is an assembly with parts and in those parts are sketches. What I am trying to do is set a layer to specific sketches as geometry is added to them. I have the code pretty much worked out in how to select the view I want all the way down to actually selecting the sketch I want to assign the layer to. Where I am getting stuck is how to piece together the code that grabs all the entities of the sketch using the DrawingCurve Method. Everything that I have seen as an example expects that the entities are manually selected but I am using a For loop to cycle thru and select the sketch I want based on name and then I set a Sketch Proxy so I can make changes (at least that is what I do when I want to hide specific sketches) Here is the code I have so far. If someone out there would be willing to help me piece this together so that it works I would be ever so grateful. Right now I get an error that "Object reference not set to an instance of an object."
Dim oDoc As DrawingDocument oDoc = ThisApplication.ActiveDocument Dim oActiveSheet As Sheet oActiveSheet = oDoc.ActiveSheet Dim oDrawingView As DrawingView oDrawingView = oActiveSheet.DrawingViews(1) Dim oRefDoc As AssemblyDocument oRefDoc = oDrawingView.ReferencedDocumentDescriptor.ReferencedDocument Dim oAssDef As AssemblyComponentDefinition oAssDef = oRefDoc.ComponentDefinition Dim oOcc As ComponentOccurrence oOcc = oAssDef.Occurrences(1) Dim oPart As PartDocument oPart = oOcc.Definition.Document Dim oDef As PartComponentDefinition oDef = oPart.ComponentDefinition Dim oSketch As PlanarSketch For Each oSketch In oDef.Sketches Dim oSketchProxy As PlanarSketchProxy oOcc.CreateGeometryProxy(oSketch, oSketchProxy) If oSketch.Name = "SK MTG Holes" Then Dim oDrawingCurveSegments As DrawingCurveSegments Dim oDrawingCurve As DrawingCurve Dim oDrawingCurveSegment As DrawingCurveSegment oDrawingCurve = oDrawingCurveSegment.Parent For Each oDrawingCurveSegment In oDrawingCurveSegments oDrawingCurveSegment.Layer = oDoc.StylesManager.Layers.Item("COUNTERSINK1.0POLY_8(913)") Next End If Next
Solved! Go to Solution.