ds-blue-logo
Preview  |  SOLIDWORKS USER FORUM
Use your SOLIDWORKS ID or 3DEXPERIENCE ID to log in.
VDVictor Davila31/03/2012

Greetings!.. I have a question for any Sloidworks VB guru, or any guru for that matter.

I am creating a curve in a VBA macro and each time I create a curve it names it by a default name. Curve-1, Curve-2 etc..

Same goes for a circle, Sketch1, Sketch2 etc...

How can I, if possible, make a curve or a sketch and give it a name so it comes out on the feature tree as the name you give it..

Im controling the variables thru a text box, so I would like the user to be able to name the sketch what he pleases without having him rename it manually.

Any help is apprecitated, and thank you very much

EDIT*******************************

Ok so playing with the code kind of got me half way there.. the problem is, the only way it would change is if I put a new name in quotations..it does not let me use a text box from a Userform to control the name. is there a work around for this? below is my code (Curve is the name of my Userform)

Dim NOM As String
Dim NUM2 As String
Dim HOLENAME As SldWorks.Feature
NUM2 = CURVE.TB_HLNM.Value


Part.SketchManager.InsertSketch True
boolstatus = Part.Extension.SelectByID2("Front Plane", "PLANE", 0, 0, 0, False, 0, Nothing, 0)
Set skSegment = Part.SketchManager.CreateCircleByRadius(X1M, Y1M, Z1M, DS * 0.0254)
Part.ClearSelection2 True

Set HOLENAME = Part.FeatureByPositionReverse(0)
HOLENAME.Name = NUM2
NOM = HOLENAME.Name

Message was edited by: Victor Davila

Message was edited by: Victor Davila