
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I got a ton of files where I need to make part with partnumber (Last 5 letter of filename) and export to DXF.
I have searched the forum and web for examples and been copy & pasting alot.
So far I have been able to type partnumber on part and make an extrude thru.
But I have now been stucked for several days.
My goal are:
-Place last 5 letters of filename on part. DONE
-Change letters to a height around 25mm / 1in. No solution
-Extrude the text. Partly done. I have to select sketch for it to Work and would like only a few millimeters deep cut
-Export the face as DXF with full filename of part name. No solution
For testing. Make a box and save it with a 6+ letter filename.
So far my ilogic code looks like this.
Format:HTML Format Version:1.0 StartHTML: 165 EndHTML: 22504 StartFragment: 314 EndFragment: 22472 StartSelection: 314 EndSelection: 314SyntaxEditor Code Snippet
oAssDoc = ThisApplication.ActiveDocument oAssDef = oAssDoc.ComponentDefinition oItemNo = Right(ThisDoc.FileName(False),5) Dim oFace As Face Dim oStyle As TextStyle oFace = ThisApplication.CommandManager.Pick (SelectionFilterEnum.kAllPlanarEntities,"Select the face") 'make sure it is a planar face If oFace.SurfaceType = SurfaceTypeEnum.kPlaneSurface Then oPlanarSurface = oFace.Geometry 'add a sketch oSketch = oAssDef.Sketches.Add(oFace) 'trying to choose an appropriate point 'assume this planar face has one edge loop only oEdgeLoop = oFace.EdgeLoops(1) oMinPt = oEdgeLoop.RangeBox.MinPoint oMaxPt = oEdgeLoop.RangeBox.MaxPoint CenterPt = ThisApplication.TransientGeometry.CreatePoint((oMaxPt.X + oMinPt.X) / 2#, (oMaxPt.Y + oMinPt.Y) / 2#, (oMaxPt.Z + oMinPt.Z) / 2#) 'get one point on the face and transform to the point2d on the sketch oTextPt = oSketch.ModelToSketchSpace(CenterPt) oTest = oSketch.TextBoxes.AddFitted(oTextPt, oItemNo) oSketch = ThisApplication.CommandManager.Pick (SelectionFilterEnum.kAllPlanarEntities,"Select the face") Dim oPartDoc As PartDocument oPartDoc = ThisApplication.ActiveDocument Dim oCompDef As PartComponentDefinition oCompDef = oPartDoc.ComponentDefinition ' Create a profile. Dim oProfile As Profile On Error Goto NoProfile oProfile = oSketch.Profiles.AddForSolid 'set direction oDirection = kSymmetricExtentDirection 'set operation oJoinOrCut = kCutOperation ' Create an extrusion Dim oExtrude As ExtrudeFeature On Error Goto NoExtrude oExtrude = oCompDef.Features.ExtrudeFeatures.AddByThroughAllExtent( _ oProfile, oDirection, oJoinOrCut) ThisApplication.CommandManager.ControlDefinitions.Item("FinishSketch").Execute iLogicVb.UpdateWhenDone = True Exit Sub NoProfile: MessageBox.Show("No closed profile found", "iLogic") Return NoExtrude: MessageBox.Show("No extrusion created, check your inputs.", "iLogic") Return Else MsgBox( "please select a planar face!") End If
Solved! Go to Solution.