Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Computer Aided Design - CAD > Solidworks > Simple macro no...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 4 Topic 10191 of 11000
Post > Topic >>

Simple macro not working

by robin_boudreault@[EMAIL PROTECTED] May 7, 2008 at 06:00 AM

I'm trying to make a macro to build a simple rectangle centered on the
origin by selecting midpoint of a side and making it horizontal with
the origin (same thing for the top line). I don't want the diagonal
construction ligne midpointed to the origin...

When I record it I get this but if I play it back I don't get it
centered. Is it possible code it so to preselect a point other than
the origin and build a centered rectangle? This is my first macro by
the way...

Somebody did it before? We often start basic rectangle centered on the
origin so I'd like to programm it.

Thank!

Robin

------------

Dim swApp As Object
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
Dim SkLine As Object
Set SkLine = Part.SketchManager.CreateLine(-0.1, 0.1, 0, 0.1, 0.1, 0)
Set SkLine = Part.SketchManager.CreateLine(0.1, 0.1, 0, 0.1, -0.1, 0)
Set SkLine = Part.SketchManager.CreateLine(0.1, -0.1, 0, -0.1, -0.1,
0)
Set SkLine = Part.SketchManager.CreateLine(-0.1, -0.1, 0, -0.1, 0.1,
0)
Part.ClearSelection2 True
boolstatus = Part.Extension.SelectByID2("Line53", "SKETCHSEGMENT", 0,
0.1, 0, False, 0, Nothing, 0)
Part.SelectMidpoint
boolstatus = Part.Extension.SelectByID2("Point1@[EMAIL PROTECTED]
",
"EXTSKETCHPOINT", 0, 0, 0, True, 0, Nothing, 0)
Part.SketchAddConstraints "sgVERTICALPOINTS2D"
Part.SketchAddConstraints "sgVERTICALPOINTS2D"
boolstatus = Part.Extension.SelectByID2("Line56", "SKETCHSEGMENT",
-0.1, 0, 0, False, 0, Nothing, 0)
Part.SelectMidpoint
boolstatus = Part.Extension.SelectByID2("Point1@[EMAIL PROTECTED]
",
"EXTSKETCHPOINT", 0, 0, 0, True, 0, Nothing, 0)
Part.SketchAddConstraints "sgHORIZONTALPOINTS2D"
Part.SketchAddConstraints "sgHORIZONTALPOINTS2D"
Part.ClearSelection2 True
boolstatus = Part.Extension.SelectByID2("Point95", "SKETCHPOINT", 0,
0, 0, False, 0, Nothing, 0)
boolstatus = Part.Extension.SelectByID2("Point1@[EMAIL PROTECTED]
",
"EXTSKETCHPOINT", 0, 0, 0, True, 0, Nothing, 0)
End Sub
 




 4 Posts in Topic:
Simple macro not working
robin_boudreault@[EMAIL P  2008-05-07 06:00:49 
Re: Simple macro not working
"Keith Streich"  2008-05-07 10:04:35 
Re: Simple macro not working
robin_boudreault@[EMAIL P  2008-05-07 08:45:57 
Re: Simple macro not working
fcsuper <fcsuper@[EMAI  2008-05-07 09:09:46 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Nov 22 2:40:45 CST 2008.