Pages

Showing posts with label Programming. Show all posts
Showing posts with label Programming. Show all posts

Wednesday, February 27, 2013

Android Application Programming Basics

Android Application Programming Basics
Today I’m going to share a few of my notes about Android Application programming basics. Recently I’ve been trying to learn how to program Android applications. This post is not directly related to CAD but I will hopefully one day be creating some Android applications for CAD users.

Android Programming Acronyms
  • SDK = software development kit
  • DP = density pixels
  • IDE = Integrated Development Environment
  • UI = User Interface

Android apps are written in Java. I think it’s much harder to learn than writing macros for CATIA V5. When you write a macro, you can type up the code in a simple text editor and it is read top to bottom like a book. When writing code for Android applications, code must be inserted into at least three different locations within the Eclipse IDE software.

Pages or screens in Android apps are known as Activities. An Intent is a communicator with another application and you use it to change screens. To create a new activity right click on package: New>Class. Give it a name and set Super class as Activity, which will be a java file. Each activity needs a layout file (.xml) created by going to New>Android xml. Name it file_name.xml. Xml is a way to organize information with structure (as opposed to just using a text file). The xml file is used to organize the layout and properties of all the text, input boxes, buttons, images, etc. Buttons use a method called OnClickListener.

Alright, that might have sounded confusing to you, especially if you’ve never programmed before, so I’m going to leave it at that for now. Would you like to learn more about Android application programming? Please let me know and I will write more detailed posts. I’ve recently created two Android applications and they are available in the Google Play store for Free here.

In your opinion, what are the best CAD apps out there?

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, 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!

Monday, December 26, 2011

Evolution of Computer Skills of a Mechanical Engineer

Trust me, I'm an Engineer! This is sad but true. Excel is a great and powerful tool. I think you could group PowerPoint into that category too. I also enjoy the engineering flow chart!

Saturday, December 3, 2011

Gift Ideas for CAD and 3D Modelers

Are you shopping for a CAD user, 3D modeler, or an engineer? Well, I have a couple of holiday gift suggestions for you.

A full-color guide to the #1 architectural drafting program—AutoCAD 2012 for Dummies. AutoCAD is the leading software used to create 2D and 3D technical drawings. Used by engineers, architects, and drafting professionals, it can be complex and is a perfect subject for the tried-and-true For Dummies format. Full-color illustrations make the instructions even easier to follow, because examples in the book appear exactly as they will on the screen.


Fully updated for the latest version of software, Kelley’s Pro/ENGINEER Wildfire 5.0 Instructor remains organized around step-by-step tutorials — the most effective way to teach and learn this procedure-intensive CAD application. Pro/ENGINEER Wildfire 5.0 Instructor provides a solid background in parametric design and constraint-based modeling. In addition, the comprehensive references make this text an all-in-one tutorial, reference, and lecture guide for students of Pro/ENGINEER.


CATIA V6 (Computer-Aided Three Dimensional Interactive Application) is the world's leading multi-platform CAD/CAM/CAE software suite marketed worldwide by IBM. It allows the user to apply its capabilities to a variety of industries such as automotive, industrial robots, electronics, manufacturing design, aerospace, and consumer goods. CATIA V6 Essentials includes all the major concepts related to the latest version of CATIA, such as installation, modes, and modeling in an easy-to-understand, step-by-step format. It also covers all the major commands and techniques and provides the reader with all of the details to learn the basics with a clear method of instruction. This comprehensive reference will help you navigate this multifaceted software with ease.


Solid Edge ST3 for Designers is a comprehensive textbook that introduces the users to direct modeling with precise control of dimension-driven design through precision sketching and selection handles using the Solid Edge ST3 software. The textbook covers all major environments of Solid Edge ST3 in both the Synchronous and Ordered modeling with a thorough explanation of all tools, options, and their applications to create real-world products.

And some shameless self-promotion. Have you ever wondered what it takes to design and build a roller coaster? At last, there’s a book that shows you. A mix of engineering and art, roller coasters are complex three-dimensional puzzles consisting of thousands of individual parts. Designers spend countless hours creating and tweaking ride paths to push the envelope of exhilaration, all while maintaining the highest safety standards. Coasters 101: An Engineering Guide to Roller Coaster Design examines the numerous diverse aspects of roller coaster engineering, including some of the mathematical formulas and engineering concepts used.

Monday, October 24, 2011

How to add amacro icon to a toolbar in CATIA V5?

There are multiple ways to initiate a CATScript macro in CATIA V5. Did you know that it is possible to invoke your macro through a tool bar icon? How do you create an icon for your macro? Go to tools >customize >commands > macros > show properties. Next, simply define a logo for your macro by picking one from the 180 plus icons to choose from (or browse to your own custom made icon) and then drag and drop it into the menu bar where you want it. It's that easy. So now you should have three ways to run your VBA CATScripts: going to Tools>Macro>Macros, hitting Alt+F8, or by clicking on your icon in a toolbar.

Wednesday, October 12, 2011

How to automatically take a picture using a catscript

Catscripts can be a powerful tool when needing to automate processes in CATIA V5. One common process which is helpful to automate is when you want to take a screenshot of a .catpart or .catproduct with a white background (to put into a powerpoint or Excelfile). This sounds like a daunting task if you are new to VB programming. I find the best thing to do is to break down this large, challenging project into smaller, more manageable tasks. Let's think about each stage we want the macro to complete:
1. Reframe on the part
2. Hide the specification tree
3. Change the background color to white
4. Take a screenshot and save it as a JPEG file
5. Change the background display color back to what it was
6. Unhide the specification tree
Now, if we take each of those steps one at a time it's not so big of a problem. I'll be explaining each of these steps in the next couple of posts starting with step one today- how to automatically reframe (or fit all in) on the part in CATIA. We'll create each step individually then combine them all into one CATScript at the end.  This tutorial will also help you learn visual basic programming and will help you write your own CATScripts.
First, go to Tools>Macro>Macros. Click "Create" and change the Macro language to CATScript. Enter a name for your macro. Copy and paste the following code.

Language="VBSCRIPT"
Sub CATMain()


Dim specsAndGeomWindow1 As Window

Set specsAndGeomWindow1 = CATIA.ActiveWindow


Dim viewer3D1 As Viewer

Set viewer3D1 = specsAndGeomWindow1.ActiveViewer


viewer3D1.Reframe


Dim viewpoint3D1 As Viewpoint3D

Set viewpoint3D1 = viewer3D1.Viewpoint3D


End Sub

What does all of the above actually mean? A CATIA VBA program or “macro” consists of a
“Subroutine” named CATMain(), called out with the line Sub CATMain(). Variables are “dimmed” (declared) and then “set” (given a value). Variables are “dimmed” as a type. A type is either a “primitive” type (single, double, integer, string, etc.) or an object type (more complex). 

Stay tuned to learn more in our next article... 

Monday, February 28, 2011

CATIA NC Machining Reverse Motion Fix

I am machining some parts in CATIA V5 R18 and if I zoom in on the vectors in wire-frame mode I am noticing areas where the tool is reversing a fraction of a millimeter, which has become an issue. I need to eliminate all of these reverse motions. My two major concerns are:

1. What is the easiest way to detect these reverse motions? Currently, I have to zoom in really close on the vectors, the only way I know how to see them in CATIA, which is a pain.
2. How do you avoid this reverse motion? What's the best way to fix them?





The answer to question number one is unfortunately there is no other way in CATIA to detect these tiny reverse motions. If you have some sort of post-processor that will usually pinpoint problem areas but if you don't have access to a post then you're out of luck. As far as concern number two, my guess is the surfaces are crap (especially if they are not native CATIA data and imported from some other system). You can try to rebuild them to get better results. Often times, I will delete the two axial moves using the toolpath editor. Then, I will select the icon to connect the path, select one of the high-lit points, and enter .000 as the value. This way, you will get a direct connection in machine feed. It's kind of weird, but if I want a Rapid connection, I will enter .1 as the value.

Also, sometimes, as in the example, you would end up with a small zig-zag motion. In that case, I will often delete a point if available or move a point along the direction before "connecting" it. As always, toolpath editor is last resort but I'll use it rather than spend a bunch of time fighting surfaces and machining operations. I always note in my programming log, any locked toolpaths, why, when, and what type of edit was made. It's good to keep a log using Excel for whenever you have to make "manual" edits of any sort.

Wednesday, April 21, 2010

Theo Jansen Mechanism Matlab Code


As promised, here is some of the Matlab code for the Theo Jansen Mechanism we posted a video of a little while back. We begin every Matlab program with the clear all command. Next are the lengths for all of the linkages.

clear all

%Link Lengths

L1=286;

L2=120;

L3=400;

L4=275;

L5=400;

L6=290;

L7=275;

L8=275;

L9=400;

L10=290;

L11=400;

L12=275;

L13=170;


 

%To get the video output:

a=1;

mov=avifile('TheoJansen.avi','COMPRESSION','None');

for theta=0:pi/20:8*pi


 

%Relating all values to theta2 of 4-bar mechanism O2ABO1

theta2=pi-theta;

ssquared=(L2)^2+(L1)^2-(2*L1*L2*cos(theta2));

s=sqrt(ssquared);

beta=asin((L2*sin(theta2))/s);

psi=acos(((L3^2)+(s^2)-(L4^2))/(2*L3*s));

lambda=acos((L4^2+s^2-L3^2)/(2*L4*s));

theta3=pi-psi+beta;

theta4=pi+beta+lambda;

theta5=lambda+beta;


 

%Finding the points relative to the motion of theta2

O1=[0,0];

O2=[-L1,0];

A=[L2*cos(theta) L2*sin(theta)];

B=[A(1)-L3*cos(psi-beta) A(2)+L3*sin(psi-beta)];


 


%Plotting the 4-bar mechanism


plot ([O1(1),A(1)],[O1(2),A(2)],'r','linewidth',3)

hold on

plot ([O2(1),O1(1)],[O2(2),O1(2)],'black','linewidth',3)

plot ([A(1),B(1)],[A(2),B(2)],'g','linewidth',3)

plot ([O2(1),B(1)],[O2(2),B(2)],'r','linewidth',3)

%Bottom triangle DEF

F=[E(1)-L12*cos(lambda+beta) E(2)-L12*sin(lambda+beta)];


 

plot([D(1),F(1)],[D(2),F(2)],'linewidth',3)

plot([E(1),F(1)],[E(2),F(2)],'linewidth',3)


 


%Link FG


G=[F(1)-L13*cos(lambda+beta) F(2)-L13*sin(lambda+beta)];


 


%Trajectory of point G


plot([F(1),G(1)],[F(2),G(2)],'linewidth',3)

Gx(a)=G(1);

Gy(a)=G(2);

plot(Gx,Gy)


 

axis([-800 400 -800 400])

hold off

a=a+1;

pause(.1)

M=getframe;

mov=addframe(mov,M);

end

mov=close(mov);


 

I left out a portion in the middle so you'll just have to figure that out by yourself!


 




Bookmark and Share