Message 1 of 5
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello to All,
i am trying to copy a sketch from an assembly into the piece parts in the assembly. i can copy the sketch into the part(s), but am having issues with the proper proxies. have searched the forums, found some helpful info (and code, thank you!), but still can't figure it out.
Sub Main() Dim oDoc As Document oDoc = ThisDoc.Document Dim oAsmCD As AssemblyComponentDefinition oAsmCD = oDoc.ComponentDefinition Dim oObjToDelete As Object Dim oTo As TransientObjects= ThisApplication.TransientObjects Dim oTG As TransientGeometry = ThisApplication.TransientGeometry Dim oAsmCompDef As AssemblyComponentDefinition = ThisServer.ActiveDocument.ComponentDefinition Dim oSketch1 As PlanarSketch Try oSketch1 = oAsmCompDef.Sketches("Sketch 1") Catch EX As Exception Logger.Debug("COULD NOT FIND SKETCH") End Try Dim oSketchPartA_Proxy As PlanarSketchProxy Dim oOcc As ComponentOccurrence 'oAsmCompDef.CreateGeometryProxy(oSketch1, oSketchPartA_Proxy) Dim oSketch2 As PlanarSketch '= oOcc.Definition.Sketches("BEVEL_CUT") For Each oOcc In oAsmCompDef.Occurrences Logger.Debug(oOcc.Name) Dim oOccPartB As ComponentOccurrence = oAsmCompDef.Occurrences.ItemByName(oOcc.Name) Dim oPartB_Def As PartComponentDefinition = oOccPartB.Definition Dim oSketchPartB As PlanarSketch = oPartB_Def.Sketches.Add(oPartB_Def.WorkPlanes.Item(2), False) Try oSketch2 = oOcc.Definition.Sketches("BEVEL_CUT") oSketchPartB = oSketch2 Catch ex As Exception ' Dim oOccPartB As ComponentOccurrence = oAsmCompDef.Occurrences.ItemByName(oOcc.Name) ' Dim oPartB_Def As PartComponentDefinition = oOccPartB.Definition Logger.Debug("sketch not found") oSketchPartB = oPartB_Def.Sketches.Add(oPartB_Def.WorkPlanes.Item(2), False) oSketchPartB.Name = "BEVEL_CUT" End Try Dim oSketchPartB_Proxy As PlanarSketchProxy oOccPartB.CreateGeometryProxy(oSketchPartB, oSketchPartB_Proxy) 'oSketchPartA_Proxy.CopyContentsTo(oSketchPartB_Proxy) Try oSketch2 = oOcc.Definition.Sketches("BEVEL_CUT") Call oSketch1.CopyContentsTo(oSketchPartB_Proxy) Logger.Debug("sketch....2") Catch EX As Exception Logger.Debug("NO SKETCH IN MODEL...." & oOcc.Name) End Try 'Call oSketch1.CopyContentsTo(oSketch2) Next End Sub
i have attached a zip with my test file, with the ilogic rule in the assembly, and here is my source code. I have commented out this line as i get an error
'oAsmCompDef.CreateGeometryProxy(oSketch1, oSketchPartA_Proxy)
any help, as always, would be greatly appreciated!!
thanks in advance!!
Solved! Go to Solution.