Pages

Wednesday, July 14, 2010

How do you write a CATIA CATScript Macro?


A question I often get asked is "how do you create vba macros in Catia?" One solution is to write a script. No, not a script for a movie, a CATScript file! To create a CATScript macro for CATIA open Notepad and write your code, then save the file with whatever name you want and type extension .CATScript instead of .txt. Here is a simple CATScript you can use as an example. This CATScript will tell you which version of Catia you are currently using, including the service pack number. Copy and paste the code into Notepad then save as CatiaVersion.CATScript.


 

Sub CATMain()

Set SystemConfiguration1 = CATIA.SystemConfiguration

Msgbox "CATIA V" & SystemConfiguration1.Version & " R " & SystemConfiguration1.Release & " sp " & SystemConfiguration1.ServicePack
End Sub


Now you are on your way to writing your own CATScript macros and automating simple and repetitive processes!

Learn how to write CATScript macros Lesson 1.

Learn how to write CATIA CATSCRIPT MACROS

Tuesday, July 13, 2010

How do you write code for Catia’s Expert Check Editor?

I've been trying to use KBE (Knowledge Based Engineering) to try and automate a checking procedure on an NC machining process in CATIA V5. The customer requirement is for all cuts to be in the climb direction, not conventional. Using the expert check editor I can implement a checking system to easily make sure all machining operations are compliant with this requirement. Syntax is the trickiest part of the KWE language, so pay close attention to every key stroke you make when programming. Here are the steps:

Knowledgeware>Knowledge Expert Workbench>Expert Check Editor

Be sure to select the KWE Advanced Language from the pull down menu. Now enter the following code:

For All entry: FX:Mfg5AxisCurveMachining; CX:Mfg5AxisFlankContouring

Body entry: /* only interested in multi axis curve operations containing the word "Rough" */

if FX->Name()->Search("Rough")>=0

{

    if FX.MfgDirectionOfCut=="MfgClimb"

    {

        ThisCheck->AddTupleSucceeded (FX)

    }

    else

    {

        ThisCheck->AddTupleFailed (FX)

    }

}


 

/* only interested in multi axis curve operations containing the word "Finish" */


 

if FX->Name()->Search("Finish")>=0

{

    if FX.MfgDirectionOfCut=="MfgClimb"

    {

        ThisCheck->AddTupleSucceeded (FX)

    }

    else

    {

        ThisCheck->AddTupleFailed (FX)

    }

}


 

/* only interested in multi axis FLANK CONTOURING operations containing the word "Chamfer" */


 

if CX->Name()->Search("Chamfer")>=0

{

    if CX.MfgDirectionOfCut=="MfgClimb"

    {

        ThisCheck->AddTupleSucceeded (CX)

    }

    else

    {

        ThisCheck->AddTupleFailed (CX)

    }

}

Monday, July 12, 2010

Catia NC Programming using Check Editor Knowledge Based Engineering


I use the check editor in Catia V5 to improve the quality of NC machining process files. All of my chamfer cuts on this particular part need to have a Tanto Fan axis. I use the code below:

`Far Side Chamfer 1\MfgParameter.5\Tool axis strategy` == "MfgTantoFan" AND
`Far Side Chamfer 2\MfgParameter.5\Tool axis strategy` == "MfgTantoFan" AND
`Near Side Chamfer 1\MfgParameter.5\Tool axis strategy`== "MfgTantoFan" AND
`Near Side Chamfer 2\MfgParameter.5\Tool axis strategy` == "MfgTantoFan" AND
`Near Side Chamfer 3\MfgParameter.5\Tool axis strategy` == "MfgTantoFan"

All of the machining operations in my part need to be climb cut. Therefore, I used this code in the Catia check editor to let me know if it somehow gets changed by accident.

`Rough Far Side.1\MfgParameter.5\Direction of cut` == "MfgClimb" AND
`Rough Far Side.2\MfgParameter.5\Direction of cut` == "MfgClimb"

Keep in mind you can't just use a plain old equals sign, you need to use the double equals. Also, it took me awhile to figure out the correct syntax for  "MfgClimb". I tried "Climb" and MfgClimb unsuccessfully before stumbling upon the successful solution.

I use a parameter to control the depth periphery (depth of cut) and the distance on the rough profile from the tool to the part. Here are the simple formulas for the check editor.

Depth_Periphery == -2mm AND RoughProfile == 1.5mm

/*Check created by Me 7/12/2010*/

Thursday, June 24, 2010

CAD Roller Coaster Model Car Concept

Working on a new concept model in part and assembly design. This is the lower chasis. modeled in Catia V5 and screenshot in 3D Via. More to come soon including the 3d xml files.

Wednesday, June 23, 2010

Best Practices for CATIA V5

There is a great thread for CATIA V5 Users:

http://www.coe.org/Collaboration/DiscussionForum/ActiveDiscussions/tabid/210/forumid/6/postid/129677/view/topic/Default.aspx

I've compiled the complete list of suggests here:

1 Never make a plane from a solid face! Reason being is that if the solid changes, it can affect the plane which can snowball into a huge mess of errors.

2. (for managers) Never purchase Catia, and expect to implement it, and get full functionality, without TRAINING, and I mean professional training.

3. Never make geometry without knowing what the 'In Work' object is.

4. Never open a R18 file in R19, and accidently save it.

5. Never use File + save + Propagate directory, as a substitute for file and directory structure management.

6. Never alter the Customer model

7. Don't do fixed bid work for less than the going contract hourly rate. To do so is just plain self torture.

8. Never do fixed bid NC programming

9. If you ignore #8 .....Never do fixed bid NC programming, for an new customer, without a signed off preplan.

10. Never Mix hybrid and .........

11. Never trust that hotfix/SP will fix the problem you reported on first round without any additional problems...

12. Leave fillets out of sketches and make them as dress-up features operations except, curves that define major features of the design should be included in the sketch.

13. Never release a service pack, to the population, before a major test regiment

14. Never load a service pack, before a major deadline.

15. Never skip going to a COE annual Conference

16. Never do nothing but whine and complain about CATIA. Sure it's fun to poke at it, and have a good laugh at DS's expense. The reality is, as Roger says: ::CATIA keeps getting better all the time"

17. Never duplicate geometry within a sketch. Keep sketches simple, and only define a single profile. Use Pattern to duplicate the profile's feature

18. Never link to anything that isn't published
19. Never use Faces, Edges, or Vertices to create new geometry. You can use the, but always create an EXTRACT element first.

20. Never exit a sketch unless everything is fully constrained. (never exit if geometry is white - everything should be green or yellow)

21. Never exit a sketch without first doing a sketch analysis.

22. Avoid using Red. Catia uses Red to 'warn'. It can become confusing.

23. Don't use translate/rotate/scale in normal design. They are useful if you get data from other CAD, but other changes should happen with changes of part specification, not by adding these commands.

24. Don't try to do everything in one part like V4. Learn Products and do your work in your own CATPart.

25. Don't use the V4 method part modeling; don't make a body and pad of every solid feature and boolean Add or Remove the body to the part. V5 features are automatically added or removed, making boolean operations unnecessary for basic part design. Use boolean operations only for grouping and special situations.

26. Don't turn on the Datum mode when making surfaces, to create isolated surfaces like in V4. Keep the parent/child relationships to make it easy to modify surface models.

27. Don't blindly create all sketches as positioned just because you heard it was better. If you do create positioned sketches, make sure you position them properly. Positioned sketches are extremely useful but aren't required in a lot of situations. (Floating sketches have their own set of issues.)

28. Use "Positioned Sketch"

29. In general: The rule of one Physical Part = one CATIA Part. Body is not Part, it's Body. (Exceptions: e.g.: Over-molded parts.)

30. If you create Contextually linked part (part with contextual links) Position the part to common origin. Typical way of getting an assembly level update cycle is:
• Part is positioned with constraints that create a Positional link between geometry of this part & other parts
• Part has contextual links that affect to this very same geometry
èeasily there is a conflict of geometry position versus geometry shape... èUpdate cycle or impossible to update.
èIf you create contextually linked part, just freeze it to space with Fix or position it with constraints from Basic planes.

31. When creating external references or internal references be thoughtful of how they are affected by changes. Think; "how flexible is this reference?" It's not always easy and sometimes requires trial and error.

32. Profile sketches should be limited to lines and as few curves as necessary to describe the geometry.

33. Learn how to build a well named / organized tree and file system. It might seem trivial on small jobs, but on the big ones it becomes an absolute necessity.

34. When creating assemblies with several constraints, LABEL THEM so you know what you're looking at when one of them breaks or fails. Do it when you create the constraint.

35. Always comment actions/knowledgeware scripts/VB scripts so you know what you did.

36. Learn and understand Links

37. Learn and understand Parameters

38. Learn and understand PowerCopies

39. Learn When and Why to use Boolean Operations. They aren't always required, but they are OK to use when they are required. If you have to go out of your way to avoid them, then use them. KISS - Keep It Simple, S(illy)

40. Try to limit the number of items that you project or intersect into a sketch (use edges). If you do create use edges, make sure to select the item ONLY from the tree. If you select the item by picking the 3D geometry, the use edge will always use a BREP, which can be unstable on future updates.

41. Check and double check your CATSettings. Understand them.