Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

??? VBScript Macro for a shaft ???

Status
Not open for further replies.

ivaior

Computer
Jun 18, 2004
4
Hi,

I am trying to generate a macro for "shaft" creation. I tried with different profiles and axes, but I cannot generate a functional macro. It gives me an error when I run it.

Here is a part of the code I have:

Set shapeFactory1 = part1.ShapeFactory
Set reference1 = part1.CreateReferenceFromName("")
Set shaft1 = shapeFactory1.AddNewShaftFromRef(reference1)
Set bodies1 = part1.Bodies
Set body1 = bodies1.Item("MechanicalTool.1")
Set sketches1 = body1.Sketches
Set sketch1 = sketches1.Item("Sketch.1")
Set reference2 = part1.CreateReferenceFromObject(sketch1)
shaft1.SetProfileElement reference2
part1.Update

And the error is "the method update failed"

Does anybody have a cue?

Thanks,
 
Replies continue below

Recommended for you

Hi,it may be the problem here in this line "Set reference1 = part1.CreateReferenceFromName("")" or "Set sketch1 = sketches1.Item("Sketch.1")",check all the names u specified in this script matches with those you have in part.

bye
Naveen
 
Tahnk you for this suggestion, but unfortunatelly, this is not the reason. The names match the ones I have in the part.

I have the feeling that the shaft is missing some information, which is strange, because when I construct it on the screen everything is OK...

Does somebody have a functional script that generates a sphere or any kind of "shaft" or "revolving" object?

Thank you!
Ivanka
 
In fact, the part1 is already defined in the file. I have the error at the very last line of the code - when it wants to update the scene:

part1.Update

If somebody has a macro that generates a shaft or a surface of revolution, please send it!

Thank you in advance!
Ivanka
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor