Thursday, November 22, 2012

Holiday Gift Ideas for Engineers

It’s time to buy the CAD user or engineer you know something special for the holidays. No matter what you celebrate, it’s a great feeling to give someone a gift. Listed below are my recommends of what to get an engineer as a present. Some of these I personally use in my job as a CAD engineer and other items are on my wishlist.


CAD/Engineering Books

Stuff You Don't Learn in Engineering School: Skills for Success in the Real World: Great advice for young engineers - all the things they don’t teach you in school!

VB Scripting for CATIA V5: Shameless self plug here. Learn how to write macros for CATIA V5.

Excel 2010 Bible by John Walkenbach: One of the best Excel resources out there.

Best eReader for Engineers

Windows RT Surface 32 GB Tablet: The best eReader or tablet device to use for engineering. One reviewer said, “I decided I wanted to get some work done on an engineering project, so I flipped out my Surface, popped the stand and keyboard, and got to work. I was halfway through crunching some large datasets in Excel when I realized that with any other tablet (including the keyboard-equipped Transformer TF300T, in my opinion the closest rival as a "productive" tablet), I would not have even considered trying to do my engineering work.”


Toys for Engineers (because you know we love to play and tinker with mechanical things)

Syma S107/S107G R/C Helicopter: The Syma S107 is so easy to control that on my first flight I had it tour my whole apartment, zooming in and out of closets and never touching an obstacle until I deliberately landed it.

Other Suggestions

engineer christmas present idea
Engineer's Motto T-shirt: If it isn’t broke, take it apart and fix it!

Tip: Don’t buy any 2D CAD software - simply download Dassault’s free version called “DraftSight.”

Give Yourself a Raise: My free report on how to make a residual income from the internet in your spare time (second edition).

What gifts are you getting your fellow CAD user for the holidays? Please let me know by commenting below!

Tuesday, October 9, 2012

How to set expiry date for CATIA macros

Some users have applications where they need their CATIA macros to expire after a certain date. This is useful to force users to quit using an older version of a macro and upgrade to the latest one. This can be accomplished by adding an expiry date to your code. After the expiry date is crossed the macro will not run the program and will only display a message box telling the user the macro is expired.

We will be using the Date function which returns the current date only. Dates in VBA are stored as number so we have to use Format in order to display the date as something that makes sense for the user to see. myDate = Format(“11/11/12”, “DD/MM/YYYY”)

Our logic in this program will be this: If the current date is greater than the expiry date (later in the year) then the expired date has passed and the macro is no longer valid, so display a message box stating such. Otherwise, display a message box stating how many days are left before the macro expires (expiry date - current date).

Download the expiry date.catvba macro

Note, this is a CATVBA (not CATScript). Check out the CATIA macro downloads page for the complete code and other CATScripts and catvba macros.

Thursday, August 16, 2012

Default Text Sizes in CATIA V5

catia default text size
How do you change the default tree text size in CATIA?

To change the default size of the text in the specification tree in CATIA V5, click on the tree. This will allow you to first set the size of the tree text to how you want it by zooming in or out. Once satisfied, instead of clicking on the tree again click on the axis system in the lower right hand corner of the screen. This should change the default size of the specification tree, even if you should close CATIA and open it again the text size should remain the same. 



How do you change the compass size in CATIA V5?

text size catia
 

Another common question is how to change the size of the compass. I recently just switched over my PC to Windows 7 OS and the compass is smaller now than it was while I was running Windows XP. In addition to this, when I right click on so geometry in the spec tree and open the Parents and Children window in CATIA the default text size is so small I can't easily read it. Thus, I have to zoom in on it every single time which is really annoying and wastes valuable time (I'm a CAD engineer and am always striving for the most efficient way to do things). There does not appear to be an option under Tools > Options to change this setting. The best answer I could find involves editing the CATIA Environment file (env.txt) as so:

CATWidthMMOfScreen= 340 which is the screen width value in millimeters => measured on your screen.
CATHeightMMOfScreen
= 200, the screen height value in millimeters => measured on your screen.
CATWidthPixelOfScreen
= 1920, the horizontal screen resolution set in your computer display properties panel.
CATHeightPixelOfScreen
=1200 is the vertical screen resolution set in your computer display properties panel.

The location of the CATIA environment file depends on how you or your administrator have set it up. Listed below are the default CATEnv file locations: 

Windows XP:
C:\Documents and Settings\All Users\Application Data\DassaultSystemes\CATEnv
C:\Documents and Settings\username\Application Data\DassaultSystemes\CATEnv

Windows 7:
C:\ProgramData\DassaultSystemes\CATEnv
C:\Users\username\AppData\Roaming\DassaultSystemes\CATEnv

Tuesday, July 24, 2012

VB Scripting for CATIA V5 Giveaway!


catia v5 automation programming tutorialAre you looking for a free VB Scripting for CATIA V5 pdf download? How would you like a chance at getting a free copy of my ebook VB Scripting for CATIA V5? One of the only online sources where you can find how to write CATIA V5 macros, this 100+ page ebook includes step-by-step tutorials to teach you CATIA automation programming. These scripting tutorials sell for $34.99. To preview a copy of the book, sign up for our free email newsletter and you'll receive a link to download it.

To enter the contest please leave a public comment on this blog post about how the VB Scripting pdf tutorial will help you! What are you going to do with the information gained from the text? That’s all there is to it! Feel free to let us know if you’re going to use it at work or at home, or any unique macro uses and you could win a free copy.
Be sure to leave a name in which I can identify you by.

The contest entry period begins today and runs through August 31, 2012. The winner will be randomly selected and announced on September 4th, 2012.


To receive an additional entry into the contest and increase your chances of winning then “like” our Facebook page and add a comment on our wall post.


Also, be sure to sign up for our free email newsletter to receive notifications about future contests (I plan on having much more frequent giveaways).

Monday, July 2, 2012

CATIA Drawing CATScript Features

Scripting Drafting features

One area I have to admit I have neglected to write about in these posts and articles is how to write CATScripts for drafting and 2D drawings. I have not used this workbench myself as extensively as some of the others (like GSD) but I will share any information or tips as I pick up on them. Here we go.

CATIA’s drafting workbench features two basic types of grouping all 2D features: Generative Drafting takes the 3D CATIA objects and represents them in 2D views within a drawing while InteractiveDrafting represents 2D features directly created in the 2D views with no 3D data associated with it.

Scripting Drafting features Overview

Listed below are some of the key features used in macros for CATIA drawings.
  • DrawingSheets and DrawingViews
  • Main View and Background view.
  • ActiveSheet.
  • ActiveView.
  • The Front View and the others
  • Generative Views
  • Interactive Views
  •  Filling the Title block
  • Extract Dimensions

DrawingSheets and DrawingViews

The DrawingDocument object aggregates a DrawingSheets collection. Each DrawingSheet of this collection aggregates a DrawingViews collection.

Main View and Background view.

A drawing contains at least two views: the background view and the Main View, that is the view in which you can draw just after creating a drawing. The ActiveSheet: The active sheet can be found in the DrawingSheets collection. The ActiveView can be found in the DrawingViews collection

CATIA Drawing viewer: The Front View and the others

A DrawingView can be the “Front View” or another view relative to the “Front View”.DrawingViewGenerativeBehavior can define both behavior: DefineFrontView() defines the “Front View” and its direction. DefineProjectionView() defines another view relative to the “Front View”
Other methods allow creating other types of views such as Section Views, Detail Views, etc. Generative Views - DrawingViewowns a “document” property that allows you to specify the associated 3D document from which the “generative view” is created.

Interactive Views - DrawingViewowns a “Factory2D” property that allows you to create 2D features.This kind of view is called an “Interactive View”.

Filling the Title block - The Texts collection allows you to create 2D texts in the drawing

Extract Dimensions - A DrawingSheet has the method called GenerateDimension() that generates dimensions automatically in all the views from the 3D geometry.

Below are example scripts to help you get started! Then sign up to the VB Scripting for CATIA V5 newsletter for even more CATIA macros.



Download Architects Cad Drawings: Subsribe To Access Our Huge Database Of Downloadable Cad Symbols, Drawings & Detail
·     
'Revised June 21, 2012
'This macro will unlock all drawing views 

Sub CATMain() 

Set drawingDocument1 = CATIA.ActiveDocument 
Set Sheets = drawingDocument1.Sheets 
Set activeSheet = Sheets.ActiveSheet 
Set views = activeSheet.Views 
  
  
Dim sSel As Selection 
Set sSel = drawingDocument1.Selection 
  
sSel.Search "CATDrwSearch.DrwView,all" 
  
For i = 1 To sSel.Count 
  
  
If sSel.Count = 0 Then MsgBox "Select one view!", vbCritical,
 "Lock/Unlock": Exit Sub 
If TypeName(sSel.Item(i).Value) <> "DrawingView" Then MsgBox 
"Selected element is not a drawing view! Select a drawing view.",
 vbCritical, "Lock/Unlock": Exit Sub 
  
Dim drawView As DrawingView 
Set drawView = sSel.Item(i).Value 
  
      drawView.LockStatus = False 
  
  
Next 
  
End Sub

'This macro will change drawing dimensions from mm to inch 


Sub CATMain() 

Dim drawingDocument1 As DrawingDocument 
Set drawingDocument1 = CATIA.ActiveDocument 
Dim selection1 As Selection 

Set selection1 = drawingDocument1.Selection 
selection1.Search "CATDrwSearch.DrwDimension,all" 
  
For i = 1 To selection1.Count 
 
 Dim Dimension1 As DrawingDimension 
 Set Dimension1 = selection1.Item(i).Value 
 Dim DimDimValue As DrawingDimValue 
 Set DimDimValue = Dimension1.GetValue 
 DimDimValue.SetFormatName 1, "NUM.DINC" 
Next
 
selection1.Clear 

End Sub 

Thursday, June 14, 2012

Screen Capture Catia Video Tutorial


Looking for a CATIA macro programming guide? I’ve created a new how-to catia video tutorial to go along with a script found in my VB Scripting for CATIA V5 ebook. The new video highlights how to use a capture photo CATIA macro. The code also includes how to toggle the specification tree allowing you to unhide or hide specification tree.

I wanted to clarify one thing from the video. You can easily modify the CATScript macro to either automatically zoom in or zoom out when taking the screen shot capture. I like to include these lines of code then simply use an apostrophe to turn them on or off. This is the lines of code I am referring to:

'zoom in
objViewer3D.ZoomIn()
‘objViewer3D.ZoomOut()
(where objViewer3D.Viewpoint3D = objCamera3D.Viewpoint3D)

Also, I save the catia capture file as .png but you can save it as TIFF, BMP, or JPEG if you want to by changing the number in this line of code or by adding your own file extension to the name (.png, .bmp).

Dim fileloc, Exten, Strname As String
Fileloc=”C:\Screen Capture\”
Exten = “.png”
Strname = fileloc & partName & exten
Objviewer3D.Capturetofile 4, strname

Here’s the process flow of the screen capture CATIA macro followed by the YouTube video tutorial:

1.       Run the macro (hit alt+F8 to set your macro libraries)
2.       Switches CATIA background color to white, hide the compass, hide specification tree.
3.       Input box 1: Enter the name you want to name the output file
4.       Input box 2:
a.        If user clicks Yes, automatically reframe and set to iso view, then take screen capture.
b.       If user clicks No, take picture as is (no reframe, use current view).
5.       Catia Screenshot is taken and saved as a .png file in a folder specified in the macro code.
6.       Resets properties including background color, unhide compass, and unhide spec tree.

 

Like I said earlier, the code in its entirety is found within my eBook, or you can try to figure it out yourself with the tips given in my CATIA macro articles and newsletters. This script is useful in car design in Catia to take catia images. 

Other useful CATScripts you will find in VB Scripting for CATA V5: Expanded Edition include:
·         Copy and paste axis system
·         Count number of parts catia macro
·         Catia tree reorder catscript
·         Capture picture vba catia

Monday, June 11, 2012

Kinect Hack Video: CATIA V5 Manipulation


KinectCAD for CATIA V5

I recently stumbled upon one of the coolest Kinect applications I’ve ever seen. The Kinect is Microsoft’s Xbox 360’s latest webcam style peripheral. This new high tech toy permits users to “be the controller” through natural user interface (NUI) by controlling the game with their voice and body movements. Microsoft took it a step further and released the Kinect software development kit (SDK) for Windows 7 allowing developers to write Kinect applications in C++, C#, or Visual Basic .NET. There are numerous “Kinect hacking” videos on YouTube. One such user has now manipulated the Kinect to provide a gesture based movement of CATIA part objects.




How to use Kinect with CATIA V5? Using this new application in development it is now possible to rotate and zoom in or out of your new Kinect 3D CAD model while standing in front of your monitor and using your arms. It gets even better: utilizing Kinect’s built in microphone there is a rudimentary speech recognition function you can use to change the rotation axes. Can you imagine creating every part in CATIA this way (or any other CAD system for that matter)?

Using the SDK V1 software for Kinect, KinectCAD has been created in Visual C# 2010. It may be a slow way to work (at first) but is a brilliant concept nonetheless. Pretty soon we’ll be seeing 3d Kinect models of all our CAD parts. It would be a great way for automakers to perform layout check in conference rooms (and funny to watch  too). Hats off to the creators and I can’t wait to see more. Checkout the Kinect video recording below:


Please note: this program is still in development.  To learn more please visit this site. So, what do you think of KinectCAD? What other applications could you see between Xbox Kinect and CATIA V5? Please leave a comment below!

Monday, June 4, 2012

CATIA V5 Macro Tutorial Update



I’ve wrote a series of how-to articles on my new site, Scripting4v5.com. These articles help beginners learn how to write VB script macros for CATIA V5. Below is a link and the title to each individual article. Also, don’t forget to sign up to my new VB Scripting for CATIA V5 newsletter where you’ll receive free CATIA macros tips in your inbox! Be sure to bookmark the articles page as well. More articles are in the works and will be added over time.

A new, updated revision of my book, VB Scripting for CATIA V5, is in the works (I have no idea when it will be complete – could be weeks or months), but until then here is a recap of the different versions (pdf and downloads) currently available. Actually, there are currently four versions/formats of VB Scripting for CATIA V5 available today, and they are as follows:

VB Scripting for CATIA V5, Kindle eBook.............................................$9.99
VB Scripting for CATIA V5, Paperback................................................$11.99
VB Scripting for CATIA V5: Expanded eBook Edition..........................$34.99
VB Scripting for CATIA V5: Expanded Edition ebook is the best value. No shipping fees and there is also a 60 day money-back guarantee - if you find the book isn't helpful you can get a full refund within sixty days and keep the ebook! Also, if you purchase this ebook, when I make additions and revisions based on YOUR feedback I will send you the latest updated copy absolutely FREE!
And speaking of feedback, I welcome any and all reviews, about my books or emails. What have you liked about them? Disliked? Is the Information what you expected? Anyone willing to submit a testimonial to be added to scripting4v5.com? If you could please response I would be very appreciative. It will only help me improve the quality of the content. Thank you.


Tuesday, May 1, 2012

Importing AutoCAD Drawings into CATIA

 How to convert DXF drawings into CATIA CATPart sketches 

There's a little trick I use when I need to copy and paste DXF 2D drawing views from AutoCAD into a sketch for a CATPart file. First of all, if you attempt to simply copy and paste a drawing view directly into the part file you may get something that looks the image picture below- a jumbled mess of data, points, and lines. 



In order to fix this problem to import the drawing data completely, open the dxf file in CATIA. Next, save the drawing as an IG2 file (which is a 2D iges file). Now open the IG2 file and copy the main view into the CATPart. Or, another option is you can rename your IG2 2D file in Windows as .igs and then open that file and it will be imported in CATIA as a 3D part file. Sometimes you have to get creative and employ these little work-arounds to get the software to do exactly what you want it to do.



Tuesday, April 24, 2012

How to Insert Symbols in Excel

I've created a new "How To" video tutorial showing you how to insert symbols, like the degree sign, into a Microsoft Excel spreadsheet, using three different methods including the character map.

Tuesday, April 17, 2012

Make spheres in CATIA with VBA


How to create spheres in CATIA with a VBA macro

One of the most asked questions of me is how do you make a sphere in CATIA V5? There are multiple methods, of course, but today I am going to share with you a method to create spheres with a VB CATScript. This will be a good tutorial for those who want to learn CATIA V5 macros. First, create a geometrical set containing nothing but a point out in space. This macro will make a new sphere at the point at a radius of a size you specify via an input box. Below is the CATScript for CATIA example. I've inserted a few screenshots along the way to help you understand script what does what.
(I use an underscore anytime a line of code gets too long and runs onto a second line but please note these need to be deleted and the code restored to one line in order for the macro to work).

Language="VBSCRIPT"
Sub CATMain() 

Msgbox "Select the geometrical set containing the points to create spheres" 

DimDocument,Part,Selection,HybridShapeFactory,HybridBodies,HybridBody,OriginElements,Plane,PlaneReference,Status
Dim InputObjectType(0),PointIndex,PointReference,HybridShapeSymmetry

Set Document = CATIA.ActiveDocument : Set Part = Document.Part : Set Selection = _Document.Selection

Set HybridShapeFactory = Part.HybridShapeFactory
InputObjectType(0)="HybridBody"
Status=Selection.SelectElement3(InputObjectType,"Select the geometrical set containing points",_
true,CATMultiSelTriggWhenSelPerf,false) 


if (Status = "Cancel") then Exit Sub
set hybridbody1 = Selection.Item(1).Value

Dim Dia As String
Dim DiaInch As Integer
Dia = InputBox("What size radius? - Spheres will have radius in mm") 



DiaMm = Dia
'~ DiaInch = Dia * 25.4
Dim hybridShapes1 As HybridShapes
Set hybridShapes1 = hybridBody1.HybridShapes

For i=1 to hybridShapes1.Count
 Dim hybridShapePointCoord1 As HybridShape
 Set hybridShapePointCoord1 = hybridShapes1.Item(i)
 Dim reference1 As Reference
 Set reference1 = part.CreateReferenceFromObject(hybridShapePointCoord1)
 Dim hybridShapeFactory1 As Factory
 Set hybridShapeFactory1 = part.HybridShapeFactory
 Dim hybridShapeSphere1 As HybridShapeSphere
 Set hybridShapeSphere1 = hybridShapeFactory1.AddNewSphere(reference1, Nothing, DiaMm,_-45.000000, 45.000000, 0.000000, 180.000000) 
 
hybridShapeSphere1.Limitation = 1
hybridBody1.AppendHybridShape hybridShapeSphere1 

part.Update
Next ‘i
End Sub

Notice in the above code where you can change the end angles if you don't want a complete sphere. After running the macro you will have a 3D surface in the shape of a sphere. Next, you can go into the Part Design workbench and do a “close surface” on the sphere geometry to create a solid part body. And now that we have our geometry we can learn how to shell the sphere if needed.

Learn how to write more CATIA catscript macros. 

Tuesday, April 10, 2012

What is CATIA UUID?


One of the biggest CATIA mysteries for new users is what is UUID and what does it stand for? UUID stands for a Universal Unique IDentifier. Every CATPart and CATProduct contains a UUID. Basically, CATIA identifies files based on their file name and their UUID. Where problems occur are when two pieces of data have the same UUID. Compounding the problem, the UUID can’t be viewed or edited with any current CATIA function. There are cases when two files may have different names but share the same UUID.

Actions which will create new UUID include:
·        File + new
·        File + new from
·        File + save As - option save as new document
·        INSERT new Product
·        INSERT new part
·        Document Template Creation

Actions which will keep the same UUID for each include:
·        File + open
·        File + save management
·        File + save
·        File + SaveAs
·        Send to directory
·        File + CLOSE
·        File + save
·        File + save ALL

Tuesday, April 3, 2012

CATIA Error: Generic Naming Graph Treatment


CATIA V5 is full of many wonderful surprises in the form of weird error messages. One of my favorite is "Click OK to terminate: Yes or No" but it doesn't matter which option you choose, CATIA still crashes and closes unexpectedly. I recently had the pleasure of discovering a new problem that I had never encountered or even heard of before. I was in the process of updating a CATPart when an update error popped up displaying: "An error occurred in Generic Naming graph treatment." The update cycle was stopped and would not continue. The issue occurred every time I tried to update the part file. Better yet, I couldn't find any information about this particular error anywhere on the internet. Has anyone else experienced this problem or have any idea what the exact cause could be? I have to admit I'm at a bit of a loss here. Fortunately, I was able to eventually work around the issue but I would still like to know what the error means. 

Join our new CAD Systems Help Facebook page for the latest updates and information
.

Monday, March 19, 2012

How do you simulate rolling in CATIA?


This is anupdate of an older post. I've created a brand new tutorial with step-by-step instructions detailing how to use CATIA V5's DMU kinematics workbench to simulate a rolling object.

First, in assembly design, create a new product and insert two new parts, one name Wheel and the other Ramp. 


I've explained this before but as a real quick overview, to create my ramp I used three sketches (overhead, side profile, and rotation about itself sketch) and combined them with laws. The wheel is a simple sketch and pad command. On my ramp I have two parallel curves 5mm apart. On my wheel I also have two parallel curves offset from each other 5mm. I added a point to one of the edges of the wheels so you can see it spin around in a circle when we simulate it. 


Add a Fix constraint to the ramp to ensure it does not move. It's absolutely vital that the curves on the wheel and the curves on the ramp are tangent to each other. Even a 0.001 gap and it will not work. Use coincidence restraints to pair them together if you have to. Also make sure your ramp is nice and smooth and much bigger than your wheel.

Now it's time to go into the DMU Kinematics workbench. Create a new mechanism and set the ramp as the fixed part. I can constrain all degrees of freedom using only two joints. The first joint is a roll curve joint between curve 1 on the wheel and curve 1 on the ramp. This is a length driven joint meaning you will input the rolling distance over time from the start point. The second joint is a slide curve joint between curve 2 on the wheel and curve 2 on the ramp.


Once you get the hang of it you can simulate more complex systems, like a full-scale roller coaster

CATIA KINEMATICS ROLLING TUTORIAL VIDEO: 



View my Introduction to CATIACATScript Macros Video Tutorial.

Thursday, March 1, 2012

Sunday, February 26, 2012

Learn how to create CATIA Macros Video Tutorial

Do you want to learn how to write VBA macros in CATIA V5? I've created a new step-by-step tutorial video to help teach you how to create macros in CATIA V5. Topics covered in the video include:
  • How to add a macro library
  • How to open and run macros
  • How to create an icon for your macros
  • Create a "hello" message box macro
I'd also like to take this time to introduce my brand new site, VB Scripting for CATIA V5! I've created an expanded edition of my book of the same name and included 100 additional pages of how-to tutorials. There are also several articles to help get you started learning the key concepts of writing VBA macros. I'll also be introducing an email newsletter with free CATScripting tips! So watch the video below and check out the new site.

 

The CATScript Msgbox code used in the tutorial:

Sub CATMain( )
  Dim strHello As String
  strHello="Hello"
  MsgBox strHello
End Sub

Tuesday, February 21, 2012

Solid Edge Synchronous and Ordered Modeling Video Tutorial

Ally PLM released their latest Lunch Byte video tutorial, this time covering the topics of synchronous and ordered modeling. These videos are meant to showcase some of the feature of Solid Edge that you may not be aware of. Watch the embedded tutorial below to learn about how synchronous modeling accelerates the design process allowing for fast and flexible edits.

Sunday, February 12, 2012

Learn AutoCAD for Dummies Review

AutoCAD is one of the leading 2D software used by engineers, architects, and designers. AutoCAD 2012 for Dummies quickly brings readers up-to-date on the latest version with all the new additions and revisions to the program. This book includes great colored illustrations and tutorials to help users better understand the material. This book was a huge help to me, someone used to running AutoCAD 2005 when I needed to, but am now making the upgrade to AutoCAD 2012. Believe it or not, even with model based definition where data is contained with 3D models, I am still needing to go to AutoCAD from time to time to whip up a quick drawing for a fixture or jig. As a mechanical engineer, it never hurts to stay up to date on the latest software available and this book is a great way to do that.

I do want to note this book is written specially for Windows users (sorry MAC peeps).

Purchase AutoCAD 2012 for Dummies and start learning how to use AutoCAD today!

Saturday, February 4, 2012

Download Architects Cad Drawings



Are you looking for AutoCAD symbols, details & drawings? Download Architects Cad Drawings contains a huge database of downloadable CAD symbols, drawings, details, and building templates in AutoCAD format. This symbols are perfect for creating floor plans or site layouts.





This is the perfect resource for CAD draftsmen and CAD technicians. There are over 6500 CAD files to download from. Click Here!

Wednesday, February 1, 2012

VB Scripting: CATPart Description Macro Example

How do you return a CATPart or CATProduct description with a macro? Using VB scripting you can use the following CATScript code to loop through all the parts within a product assembly and return what the description is. When you right click on a part within an assembly you will actually see two description boxes - component and product (pictured below). 


The top description name in the box is for the component level and can be called using DescriptionInst which returns or sets the product's description for a component product.  The bottom description name is for the product and is found through our script using DescriptionRef which set's the product's description for a reference product and is a property in the object product. Getting the part description may be useful in creating bills of materials or other part list documents.

Sub CATMain()


Dim productDocument1 As Document

Dim product1 As Product

Dim products1 As Products


Set productDocument1 = CATIA.ActiveDocument

Set product1 = productDocument1.Product

Set products1 = product1.Products


'count the number of CATParts within the catproduct

partcount=product1.Products.Count

msgbox"CHECK: The number of parts is "&partcount&". Please click OK to continue."


Dim i As Integer


'loop through all parts

For i=1 to partcount


'apply design mode to each part

products1.Item(i).ApplyWorkMode DESIGN_MODE


Dim partDoc1 As PartDocument

Set partDoc1=products1.Item(i)


Dim getDes, getDes2 As String

getDes = partDoc1.DescriptionInst

getDes2 = partDoc1.DescriptionRef


Msgbox "Component description is " & getDes& " and Product Description " & getDes2


Next 'i


End Sub



To rename (or to enter a new name) to your part description field use this code by adding it to the above text during the i loop, before Next and after the msgbox:


partDoc1.DescriptionRef = "Test"

partDoc1.DescriptionInst = "CompTest"&i


The first line will add "Test" to each product description field while the second line will add "CompTest" and the loop number. So for the first part in your assembly where i=1, after running the macro the component description will read "CompTest1", the next part "CompTest2" and so on.


See more examples like these in my new How To book VB Scripting for CATIA V5.  Visit my new site for even more CATIA macro programming tips here!


unpublic 

Saturday, January 28, 2012

Solid Edge simulation express video

Ally PLM returns with another video edition of Lunch Bytes, this time talking about Solid Edge simulation express. Watch the Solid Edge video tutorial below.
 

Monday, January 16, 2012

Dealing with Different Versions of CATIA

Only one version of CATIA V5 can be registered with Windows at a given time. If you have R16, R17, and R18SP2 installed on your PC, only one of these is currently registered. You can find which one is registered by looking at the directory when you register. To automate a specific version of CATIA you first have t register that version with Windows. Here are the steps to un-register or re-register a CATIA V5 version:
 
1.        Reboot your pc
2.        Open a command prompt
3.        CD to the unload directory of the version of CATIA you want to un-register (i.e. “c\program files\dassault systemes\B15\intel_a\code\bin”)
4.        Run the command “cnext-unregserver”
5.        Open up the task manager and wait until the “cnext” process stops running (which may take a few minutes)
6.        CD to the unload directory of the version of CATIA you want to register (i.e. “c\program files\dassault systems\B16\intel_a\code\bin”)
7.        Run the command “cnext-regserver”
8.        In the task manager again, wait until the “cnext” process stops
9.        Open up VB and check that the correct version is registered
10.        Please note this only needs to be done between full releases and not service packs!