Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Rectanular Pattern Sketch Lines? Possible? vs 2019

2 REPLIES 2
Reply
Message 1 of 3
Tiffany_Hayden_
323 Views, 2 Replies

Rectanular Pattern Sketch Lines? Possible? vs 2019

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.

EESignature

2 REPLIES 2
Message 2 of 3
S_May
in reply to: Tiffany_Hayden_


@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.

Message 3 of 3
Tiffany_Hayden_
in reply to: S_May

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.

EESignature

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report