Can I sketch a symmetric rectangle in a single step?
Can I sketch a symmetric rectangle in a single step?
(OP)
Is there an easy way to sketch a rectangle that will be centered and symmetric with the orgin? I find myself defining this sketch quite often and I'm wondering is there's some kind of control-drag way of defining a rectangle that will make this a quicker process.
For reference, I currently sketch a rectangle and then sketch centerlines from the orgin to the midpoints of the top and right side. I then define the center lines as vertical and horizontal. I'd love to find a faster way.
-b
For reference, I currently sketch a rectangle and then sketch centerlines from the orgin to the midpoints of the top and right side. I then define the center lines as vertical and horizontal. I'd love to find a faster way.
-b






RE: Can I sketch a symmetric rectangle in a single step?
"Art without engineering is dreaming; Engineering without art is calculating."
Have you read FAQ731-376: Eng-Tips.com Forum Policies to make the best use of Eng-Tips Forums?
RE: Can I sketch a symmetric rectangle in a single step?
-b
RE: Can I sketch a symmetric rectangle in a single step?
2. Draw a single construction line from one corner to the opposite corner.
3. Place a point at the mid-point of the construction line.
4. Constrain that point to the origin.
finisher SW 2007
RE: Can I sketch a symmetric rectangle in a single step?
RE: Can I sketch a symmetric rectangle in a single step?
"Art without engineering is dreaming; Engineering without art is calculating."
Have you read FAQ731-376: Eng-Tips.com Forum Policies to make the best use of Eng-Tips Forums?
RE: Can I sketch a symmetric rectangle in a single step?
RE: Can I sketch a symmetric rectangle in a single step?
CODE
Dim swApp As Object
Dim Part As Object
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long
Dim FeatureData As Object
Dim Feature As Object
Dim Component As Object
Sub main()
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
Part.ClearSelection2 True
Part.SketchRectangle -0.03093212735166, 0.04488191027496, 0, 0.0511492040521, -0.02506917510854, 0, 1
Part.ClearSelection2 True
Part.CreateLine2(0.0511492040521, 0.04488191027496, 0, -0.03093212735166, -0.02506917510854, 0).ConstructionGeometry = True
Part.ClearSelection2 True
Part.SetPickMode
boolstatus = Part.Extension.SelectByID("Line5", "SKETCHSEGMENT", 0.01516280752533, 0.0141519536903, 0, False, 0, Nothing)
boolstatus = Part.Extension.SelectByID("Point1@Origin", "EXTSKETCHPOINT", 0, 0, 0, True, 0, Nothing)
Part.SketchAddConstraints "sgATMIDDLE"
Part.ClearSelection2 True
boolstatus = Part.Extension.SelectByID("Line5", "SKETCHSEGMENT", 0.01516280752533, 0.0141519536903, 0, False, 0, Nothing)
boolstatus = Part.Extension.SelectByID("Point1@Origin", "EXTSKETCHPOINT", 0, 0, 0, True, 0, Nothing)
boolstatus = Part.Extension.SelectByID("Line2", "SKETCHSEGMENT", -0.03133646888567, 0.01051287988423, 0, False, 0, Nothing)
boolstatus = Part.Extension.SelectByID("Line1", "SKETCHSEGMENT", -0.01799319826339, 0.02587785817656, 0, True, 0, Nothing)
boolstatus = Part.Extension.SelectByID("Line4", "SKETCHSEGMENT", 0.03012344428365, 0.001213024602026, 0, True, 0, Nothing)
boolstatus = Part.Extension.SelectByID("Line3", "SKETCHSEGMENT", 0.01758885672938, -0.02466483357453, 0, True, 0, Nothing)
Part.ClearSelection2 True
boolstatus = Part.Extension.SelectByID("Line1", "SKETCHSEGMENT", -0.009502026049204, 0.02709088277858, 0, False, 0, Nothing)
boolstatus = Part.Extension.SelectByID("Line2", "SKETCHSEGMENT", -0.03052778581766, 0.01293892908828, 0, True, 0, Nothing)
boolstatus = Part.Extension.SelectByID("Line3", "SKETCHSEGMENT", 0.01475846599132, -0.02709088277858, 0, True, 0, Nothing)
boolstatus = Part.Extension.SelectByID("Line4", "SKETCHSEGMENT", 0.02891041968162, -0.01051287988423, 0, True, 0, Nothing)
End Sub
Nothing but a recorded macro, not cleaned up or anything.
For the record, I think this is the crappiest macro I've ever posted here, but I use it all the time. I have it mapped with a keyboard shortcut.
RE: Can I sketch a symmetric rectangle in a single step?
Dan
www.eltronresearch.com
RE: Can I sketch a symmetric rectangle in a single step?
Chris
SolidWorks/PDMWorks 08 2.0
AutoCAD 06/08
ctopher's home (updated 10-07-07)
RE: Can I sketch a symmetric rectangle in a single step?
That is also how the "rectangle" macro is done found on the CD of the Solidworks Bible.
Flores
RE: Can I sketch a symmetric rectangle in a single step?
I hope it works. ;)
Chris
SolidWorks/PDMWorks 08 2.0
AutoCAD 06/08
ctopher's home (updated 10-07-07)
RE: Can I sketch a symmetric rectangle in a single step?
Or this one
Chris
SolidWorks/PDMWorks 08 2.0
AutoCAD 06/08
ctopher's home (updated 10-07-07)
RE: Can I sketch a symmetric rectangle in a single step?
Function over form. I'll use this quite often. Thanks.
Joe
SW Office 2006 SP5.1
P4 3.0Ghz 1GB
ATI FireGL X1
RE: Can I sketch a symmetric rectangle in a single step?
Midpoint is selected by right clicking on the line and choosing from the menu.
RE: Can I sketch a symmetric rectangle in a single step?
Eric
RE: Can I sketch a symmetric rectangle in a single step?
RE: Can I sketch a symmetric rectangle in a single step?
CODE
Dim Part As Object
Dim SelMgr As Object
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long
Dim Feature As Object
Sub main()
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
Set SelMgr = Part.SelectionManager
swApp.ActiveDoc.ActiveView.FrameState = 1
Part.ClearSelection2 True
Dim vSkLines As Variant
vSkLines = Part.SketchManager.CreateCornerRectangle(-0.07072414660869, -0.03687367058217, 0, 0.07599696221126, 0.04203082730694, 0)
Part.SetPickMode
Part.ClearSelection2 True
boolstatus = Part.Extension.SelectByID2("Line3", "SKETCHSEGMENT", -0.009611839420063, 0.04228868514318, 0, False, 0, Nothing, 0)
Part.SelectMidpoint
boolstatus = Part.Extension.SelectByID2("Point1@Origin", "EXTSKETCHPOINT", 0, 0, 0, True, 0, Nothing, 0)
Part.SketchAddConstraints "sgVERTICALPOINTS2D"
Part.SketchAddConstraints "sgVERTICALPOINTS2D"
boolstatus = Part.Extension.SelectByID2("Line2", "SKETCHSEGMENT", -0.07356058280732, -2.578578362389E-04, 0, False, 0, Nothing, 0)
Part.SelectMidpoint
boolstatus = Part.Extension.SelectByID2("Point1@Origin", "EXTSKETCHPOINT", 0, 0, 0, True, 0, Nothing, 0)
Part.SketchAddConstraints "sgHORIZONTALPOINTS2D"
Part.SketchAddConstraints "sgHORIZONTALPOINTS2D"
Part.SetPickMode
Part.ClearSelection2 True
End Sub
RE: Can I sketch a symmetric rectangle in a single step?
Dan
www.eltronresearch.com
RE: Can I sketch a symmetric rectangle in a single step?