×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Macro chokes on Parameters.Item("X Axis")

Macro chokes on Parameters.Item("X Axis")

Macro chokes on Parameters.Item("X Axis")

(OP)
OK, got another question.  In R12.4.15, I opened an existing IGES file and immediately started recording a macro to create a single pad from a single surface in the X direction.  I closed the file without saving changes, re-opened the same IGES file, and tried to run the macro.  It failed, giving me the error "The method Item failed" in reference to the line "Set hybridShapeLineExplicit1 = parameters2.Item("X Axis")" ( a more complete version of this code follows below).  The macro is in VBScript.  Do I need to have the macro create a line in the X direction?  Or is there something else that needs done?  When macros won't even work when running the macro from the exact same point that you started recording from, it makes it a bit difficult to figure out what's going on.  As promised, here's the relevant code that CATIA recorded.

Sub CATMain()
...
Set reference1 = part1.CreateReferenceFromName("")

Set pad1 = shapeFactory1.AddNewPadFromRef(reference1,20.00)

Set parameters1 = part1.Parameters

Set hybridShapeSurfaceExplicit1 = parameters1.Item("surfname")

Set reference2 = part1.CreateReferenceFromObject(hybridShapeSurfaceExplicit1)

pad1.SetProfileElement reference2

Set parameters2 = part1.Parameters

Set hybridShapeLineExplicity1 = parameters2.Item("X Axis")
' ^^ this is where the macro fails

Set reference3 = part1.CreateReferenceFromObject(hybridShapeLineExplicit1)

...

End Sub

So, why does it choke on the reference to the X Axis?  Thanks for the help in advance.

RE: Macro chokes on Parameters.Item("X Axis")

(OP)
Ok, never mind, I figured that one out.  Here's another one:
I am calling out a draft in a macro, and I am trying to automate it.  When the face is picked and I display it in a macro, it comes up as:

Set reference3 = part1.CreateReferenceFromBRepName("Rsur:(Face:(Brp:(Pad.1;0:(Brp:
(GSMBiDim.1;2)));None:();Cf9());WithTemporaryBody;WithoutBuildError;
WithSelectingFeatureSupport)",pad1)

Since this line is in a loop which can reference other pads other than Pad.1, I'm pretty sure this line needs to change (especially with the references to Pad.1 and GSMBiDim.1).  The plan is to : take surface, build pad, draft 4 sides of same pad, add part body, index to next surface, repeat until finished with all surfaces.  I attempted to use a variable called counter and use it with the syntax Pad.counter, which failed (as you can tell, VBScript isn't exactly my strong suit).  So the question is:  how do I get this line to reference the faces of the most recently built pad?  Thanks for the help in advance.

RE: Macro chokes on Parameters.Item("X Axis")

I assume you have grouped all surfaces in the same set.
All the HybridShapes (surfaces, intersects,trims, joins) can be elements in this set. Catia knows exactly how many there are in this set.

It is defined by the .Count method but to loop it is better to use the For Each statement. This will loop through all the entities in the set in my case name MySurfaces

Sample code

Sub CATMain()

Set partDocument1 = CATIA.ActiveDocument

Set part1 = partDocument1.Part

Set hybridBodies1 = part1.HybridBodies

Set hybridBody1 = hybridBodies1.Item("MySurfaces")

Dim s

For Each s in hybridBody1 ' select each element in my set

'........Your Code Here

Next s   ' Loop

End Sub


P.s Your code

Set reference3 = part1.CreateReferenceFromBRepName("Rsur:(Face:(Brp:(Pad.1;0:(Brp:
(GSMBiDim.1;2)));None:();Cf9());WithTemporaryBody;WithoutBuildError;
WithSelectingFeatureSupport)",pad1)

This is referencing the surface of a solid element and not a surface directly. It is better to use the method

.CreateReferenceFromObject

Regs

RE: Macro chokes on Parameters.Item("X Axis")

(OP)
Regs,

Yeah, I have that loop in my macro.  The loop works as I need it to.  And I do realize I am calling out the face of a solid; I need to in order to draft the solid it pertains to.  So, unless there's a better way of somehow referencing that face, that's all I've got for now.   

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources