I am working on creating a rectangle and then wanting to pattern the two lines. I can't seem to find anything in the help to rectangular pattern sketch lines in the API help. Is this something that can be done? The other solution is to pattern the extrusion after it is cut. I don't know if that will be easier.
Thanks in advance.
Tiffany
Tiffany Hayden
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
@Tiffany_Hayden_ schrieb:
I am working on creating a rectangle and then wanting to pattern the two lines. I can't seem to find anything in the help to rectangular pattern sketch lines in the API help. Is this something that can be done? The other solution is to pattern the extrusion after it is cut. I don't know if that will be easier.
Thanks in advance.
Tiffany
... please attach pictures + sketches and models + drawings (pack models by pack and go + ZIP), create patterns for sensitive data.
Hi @S_May
I'm using the below code to create my rectangle. The code receives input from the user via msgbox to where they want the box to start then it puts the rectangle where it needs to be adjusted to the users wants. I also have not added the extra dimensions to fully constrain the box to the sketch. I'm working on that today. So that will need to be added. But this should get you close to where you need to be.
On my thing I think you are right I was thinking about it yesterday and that may be faster than adding to the sketch. The rectangular pattern of the extrude feature itself.
Dim oDoc As PartDocument: Set oDoc = ThisApplication.ActiveDocument Dim oPartDef As PartComponentDefinition: Set oPartDef = oDoc.ComponentDefinition Dim oSketch As PlanarSketch Dim oSketches As PlanarSketches: Set oSketches = oPartDef.Sketches Dim i As Integer: i = 1 For i = 1 To oSketches.Count If oSketches.Item(i).Name = "OPENING SKETCH" Then Set oSketch = oSketches.Item(i) 'test msgbox
MsgBox ("Sketch") End If Next 'This is my specialty input box. You are just getting values from the user for where the box should be. Dim oRectangleDims As String: oRectangleDims = box_Multi(BuildArray("TO MIDDLE FIRST OPENING;OFFSET FROM BOTTOM;OPENING WIDTH;OPENING HEIGHT; QTY", ";")) Dim oTG As TransientGeometry: Set oTG = ThisApplication.TransientGeometry ' Draw a rectangle with the corner at (0,0)
' build array just is an array from a string. Conversion to inches from cm. Dim width As Double: width = (CDbl(BuildArray(oRectangleDims, ";")(2)) * 2.54) Dim height As Double: height = CDbl(BuildArray(oRectangleDims, ";")(3)) * 2.54 Dim oDistToMidRect As Double: oDistToMidRect = CDbl(BuildArray(oRectangleDims, ";")(0)) * 2.54 Dim oOffsetFromBottom As Double: oOffsetFromBottom = CDbl(BuildArray(oRectangleDims, ";")(1)) * 2.54 Dim oRectangleLines As SketchEntitiesEnumerator: Set oRectangleLines = oSketch.SketchLines.AddAsTwoPointRectangle( _ oTG.CreatePoint2d(oDistToMidRect - (width / 2), oOffsetFromBottom), _ oTG.CreatePoint2d((width / 2) + oDistToMidRect, height + oOffsetFromBottom)) ' Get the third line from the collection returned. ' This will be the top line. Dim oDimLine As SketchLine: Set oDimLine = oRectangleLines.Item(3) ' Create a dimension between the end points of the line. Call oSketch.DimensionConstraints.AddTwoPointDistance(oDimLine.StartSketchPoint, oDimLine.EndSketchPoint, _ kAlignedDim, oTG.CreatePoint2d(width / 2, height + 1)) ' Get the fourth line from the collection returned. ' This will be the left line. Set oDimLine = oRectangleLines.Item(4) ' Create a dimension between the end points of the line. Call oSketch.DimensionConstraints.AddTwoPointDistance(oDimLine.StartSketchPoint, oDimLine.EndSketchPoint, _ kAlignedDim, oTG.CreatePoint2d(-1, height / 2)) oSketch.ExitEdit
Tiffany Hayden
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Can't find what you're looking for? Ask the community or share your knowledge.