I've seen several solutions pertaining to getting points
coordinates to and from Excel spreadsheets and never found anything
I personally liked that well. I would like to offer everyone
two macros of my own design, I believe you will enjoy them.
They are written in MS VBA from within CATIA. Let me know
what you think.
Rename the txt files to bas and you can import them into a VBA
project in CATIA.
1. Export points to Excel:
The first macro asks for a Set with points, or uses the one
preselected if it is not empty. Next is the option to export
in 3 or 4 column format (with or without element names).
Next, Excel asks for the range to put the XYZ values into. If
you have, for example 200 points and select a range of 40 rows, you
will continue to be asked for ranges until all points are used, or
you cancel (multi-page report, etc).
2. Import points into CATIA:
This macro will create blank parts if one is not open/active.
Excel will ask for the range with the XYZ coordinates, and CATIA
will build points. Blank or incomplete rows are skipped.
EDIT: Link added, hopefully it is easier to find this way
Milton Hartung
Jay Evans
I am trying to run the first script to export points, but I am getting an error. I am no expert in scripts, so could you please help? Here is what I have done:
Copied the text from your first file. Went into catia, went to tools, macros, created a new macro and chose MS VBScript as the language. I pasted in the text, and saved, and tried to run the macro and get this error:
Execute the script "export points.catvbs".
The scripting engine for MS VBScript has reported the following error:
Source: Microsoft VBScript compilation error
Description: Syntax Error
Statement: On Error GoTo ErrHandler
Line: 11
Column: 18
If you could provide any help that would be great. It would be very beneficial to be able to export point locations to excel or text files. Thanks.
--Jay
Milton Hartung
1. Within CATIA, click Tools -> Macros->Macros.
2. Click the 'Macro libraries' button.
3. Under 'Library type:' choose 'VBA Projects', then click the 'Create new library' button. Enter the path and file name you want here.
4. Close the 'Macro Libraries' window.
5. Within CATIA, click Tools->Macros->VB Editor.
6. Select the new Library from the tree on the left side, then click File->Import File.
7. Set 'Files of type' to All *.*, and browse and select to where you saved the .txt files from me. Pick one and repeat 7 for the other.
8. Lastly, before exiting VB Editor, click Tools->References. Find 'Microsoft Excel 11.0 Object library' and check it. If it is Excel 9 or 10 or 12 or something, it should still work fine. 11.0 is just what is with Office 2003.
9. Save the VB Project and close the Editor.
10. Now in Tools->Macros you can run these modules you just imported. If you have CATScript and Catvbs macros that you need as well, simply change the 'Current macro library or document' to the Macro folder you had defined before.
Look back over my original post for some usage ideas. And let me know if you have other questions.
Jay Evans
Thanks so much for your detailed explanation. The import points works, however I still have trouble with the export as follows:
On Winxp 64 bit, R17sp8:
The macro runs just fine, but always exports points as 0,0,0 coordinates.
On Winxp32 bit, R17sp7:
The macro attempts to run, but comes up with an error (something like Get mo Sel not valid object) I'll have to test again to see the exact error.
If I could just get the export points working this would be perfect. Your code is great an well-commented (unfortunately I have little experience with vba so it is hard for me to debug).
Only other thing, the points are in mm. (This is not a huge deal, as I can convert them in excel before or after importing/exporting) but it would be nice not to have to do this, if there is an easy way to change it.
Thanks again Milton.
--Jay
Milton Hartung
Thanks for your kind words. I did try to make these macros in good form, but they are admittedly written with only one environment in mind, our own. But a couple simple changes should get this going for you.
First, regarding Win64, I saw this post the other day:
http://www.coe.org/Collaboration/DiscussionForum/ActiveDiscussions/tabid/210/view/topic/forumid/10/postid/113750/Default.aspx
As excited as I have been about 64-bit, it just keeps disappointing. But that is a WHOLE other topic haha.
Regarding your error with your 32-bit install, I'll see what I can come up with. Let me know the full error message especially line numbers if it says, and if it is in the ExportExcel or ExportText, and if possible explain at what point it fails (immediately, after asking delimiter, etc).
On to converting mm to in. CATIA is storing these as mm regardless of your params and measures. Just start using mm! Ha, seriously though, the following few lines will fix you right up, and convert right in the macro.
ImportFromExcel, lines 81 - 83 add right before the closing paren:
* 25.4
ImportFromText, lines 123 - 125 AND 132 - 134 add right before the closing paren:
* 25.4
ExportToExcel, insert these lines at line 115
'convert from mm to in
coords(0) = coords(0) / 25.4
coords(1) = coords(1) / 25.4
coords(2) = coords(2) / 25.4
ExportToText, insert these lines at line 91
'convert from mm to in
coords(0) = coords(0) / 25.4
coords(1) = coords(1) / 25.4
coords(2) = coords(2) / 25.4
I will probably add a proper fix to these as soon as I can, like a prompt for mm/in or something easy to switch, to make it more useful to more people. Keep me posted Jay, we'll make it work!
Alasdair Ryder
Hi Milton,
Just set up and installed your macros & just wanted to say many thanks. They've worked a treat and saved me a lot of effort.
Gratefully,
Alasdair
Jay Evans
Now if only they would fix 64bit version...
Thanks a ton Milton. This is a really nice program to have.
--Jay
COE Administrator
Milton Hartung
To All,
Taking to mind the possible needs others might have for a Point Coords macro, I have redone my previously posted code. The attached is a complete CATVBA project. These new macros roll the Excel and Text file macros all into one GUI. There are checkable options here instead of multiple question pop-ups as the program runs. By editting the UserForms, others can set their own default options very easily. Options include:
- Import/Export to open Excel doc OR text document
- Scale values to mm, in, or by a custom scale
- Keep point names while importing or exporting
- Select the precision
- Choose the delimiting character while importing or exporting
To use this macro project:
- Copy the CATVBA file to a network location.
- On the CATIA Macro dialog, click Macro libraries.
- Click Add Existing Library
- Browse to it and click Open
- Close the Macro Libraries dialog
- Now in the CATIA Macro dialog, you can select the new library from the drop-down box.
- Click Edit to launch the VB editor
- Click Tools -> References and choose the Microsoft Excel Object Library and click OK.
If you have issues, bugs, requests, or kind words, please let me know!
John Stick
Very nice this macro !
Only one request: to retain (to keep) path of the last used file.
Thanks,
John
Milton Hartung
Ah, very good idea! Thanks for the inspiration!
These are updated so ALL paths, options, and values are rememberd via the Registry, per user it looks like based on the location (HK_USERS\S-1-5-21-...\Software\VB and VBA Program Settings\). The only thing not remembered is the filename part of the export filename path.
I look forward to your feedback!
Jay Evans
The last two iterations are great (with the prompt), but I now get an error and it won't finish running.
Trying to export points, I get the first prompt so I set all my options, then I get the prompt to select a geometric set. As soon as I click on the geo. set, I get the error:
"Unexpected Error 438 (object doesn't support this property or method)"
This is on winxp 32bit, R17 SP8. I made sure to add the tools->references->excel link library and follow the other steps as you suggested.
Any idea what it could be? I am really excited to get this working.
--Jay
Milton Hartung
Someone requested adding support for exporting the coordinates relative to a selected axis system. So, I will have a new version up very very soon. Right now, I've only added support for exporting with an axis. Could those that would use this functionality tell me, would it be useful to add similar functionality while importing points?
Milton Hartung
This is updated to include the option to export your point values based on a selected axis. Thank Cliff Johnson for the math dealing with the transformations!
The import functions don't yet do anything with a selected axis, possibly this will be added later.
Hope it is useful!
Vien Ba Nguyen
I do not have VBA library build into my CATIA software. The VBA library when I go to Tools>Macros>Macros Libraries isn't exist. The VBA editor isn't available either.
I made a search on google about adding VBA library to CATIA and found nothing but run around and useless methods for which I do not understand.
Some suggesting that I have to register CATIA as Microsoft embedded OLE server. I do not know what that's mean.
I am in charge of 3D drawing for an aircraft design and in desperate need of finding a way to enter airfoil coordinates from an excel spreadsheet into CATIA.
So far the only method I know is plotting point point and it takes forever. There are over 70 coordinates per airfoil and I have to continuously drawing new airfoil design. There has got to be a quicker way and I found it by employing the method of macros.
My dilemma is that my CATIA software does not contain VBA library and script. Is there a way to add VBA library to CATIA.
Thank you in advance.
Milton Hartung
Vien Ba Nguyen
Luenyar,
My operating system is window vista 32 bit. My CATIA software is V5R17. I do have microsoft office softwares installed and that include VBA.
I have no idea why the VBA library doesn't showing up. If you do have some CATscript macros that can help me import point coordinates from an excel spreadsheet that would be so helpful.
Thank you
Vien Ba Nguyen
I've found the answer. VBA library doesn't install during CATIA instalation. You have to go back to the CATIA CD's directory and open up the VBA folder. In there there's an executable file called VBA6.msi. Run that and problem solved.
Thank you for your help though. Your macros look great!!!
Jay Evans
First I just have to say a big THANK YOU as this macro works great and will probably save me much time and frustration. I very much appreciate your contributions.
The new feature to use an existing axis system is WONDERFUL!
I do have two questions:
1. How hard would it be to have it only output x and y coordinates and just ignore the z-value?
2. I still can't get it running under winxp 64 and 64 bit catia. I go thru the script just fine with all the prompts, and one of 2 things happen:
a. if I DON'T use another axis system, it runs fine but the coordinates of the point are always 0,0,0
or
b. if I try to use another axis system, instead of the "success" message I get the error: "Points (0) raised an unexpected error 1001 (Zero length vector cannot be normalized)."
This is a brand new catpart with nothing in it but a test point, and v5R17 SP8. I also tried with same result with R18 SP4.
These are not big issues by any means but I thought I would put it out there in case there is an easy fix. Thanks again Milton (and everyone who contributed).
--Jay
Milton Hartung
If you want to modify these macros to output to specific forms and only want XY I think you can just change a couple things in the ExportToExcel function. The first thing is the section that gets your option to export the point names. Reduce each by 1
If (tfUseNames = True) Then
expectedColumns = 4
Paul Ilenda
I just imported 1500 points and didnt have to sit there and manually click on each 1 to create a point. This macro will save me lots of time!
Tell me what kind of beer you drink and what your ship address is, I'll send over a microbrew from Atlanta.
THANK YOU!!
Panagiotis Davaris
I am using Catia R18 and I tried the vba macro from Milton without luck. I execute the macro and I get no reply!
Does any body have any recommendations.
Milton Hartung
All I can really suggest are the steps here to get it into CATIA, then follow the step regarding 'Microsoft Excel 11.0 Object library' by changing to the version that shipped with your install of Microsoft Office. Other than those steps I probably couldn't troubleshoot most usage problems. I am using with these conditions:
Windows XP SP3 32-bit, Microsoft Office 2003, CATIA V5R18 SP6+Supplier Integration Hotftix.
Sorry, and good luck.
Panagiotis Davaris
Hi,
My level is R18 SP4, office 2003. The strange is that when I execute the macro nothing happens. I followed all the steps and I checked 'Microsoft Excel 11.0 Object library' (attached image).
Very strange! Doesn't work also in R19!
Thank you very much.
Tim Linke
This application worked GREAT but now gives me a "compile error, can’t find project or library". In checking Tools> Reference in the VB editor if shows the following library as MISSING: CATIA V5 EMOXx CATIAv5Intergration Object Library. The location of this library is supposed to be C:\Programs\DassaultSystems\B17\intel_a\code\bin\mx…
All the other libraries referenced by the macro are in C:\Programs\DassaultSystems\B18\... think I just need to point the CATIA V5 EMOXx CATIAv5Intergration Object Library reference to the B18 file that replaces the C:\Programs\DassaultSystems\B17\intel_a\code\bin\mx… file.
I cannot find the a file in B18 named something like CATIA V5 EMOXx… or starts with mx. Would you know wha the new/correct file in B18 would be or haven't you had any trouble like this running in v18? If you don't think this is the problem let me know.
Thanks
TL
Milton Hartung
@Panagiotis:
Have you tried without 'Microsoft Office 12.0 Object Library'? Its
the only other thing I can recommend, as I do not have it checked
in my case.
@trlinke:
These plus our other macros I've created still worked fine on
migrating to R18. On scanning my references, I can't find anything
similar to the specific file you mentioned, nor have I found
anything named similar in /code/bin. I can only offer the
suggestion to try unchecking it? I wish I could offer more help,
but like I said my CATIA administration experience is long (7
years), but narrow (only my current company).
Maybe someday I'll break all my macros and convince the boss I need
CAA or whatever to fix them heh. Perhaps a proper CATIA function
would work for a wider audience? I wish I knew =P
@x64 users:
I forgot to mention, that I did a couple small brief tests on the
x64 machines we have now (running Vista Business x64 and with
Office 2003). As far as I could tell, both the import and export to
excel worked fine. It might make a difference that I've installed
the x86 CATIA code instead of the x64 based on both bad personal
experiences and advice from others.
Good luck, sorry I can't be more helpful.
Tim Linke
@LUENYAR: It dosen't seem that my reply got added to the thread so I wanted to say thanks for your recomendation. I thought I had tried unchecking the MISSING library but when I tryed it again, the script worked fine. Thanks again for the recomendation and for creating the macro to start with.
TL
John Gustaf Almquist
Hi Milton!
Your macro is brilliant! It has saved me tonnes of work. Thank you!
I have however made feeble attempts to modify it. I could really benefit from a function where the imported points overwrite the ones already in the part (with the same names) so that they can manipulated in Excel. Do you know if this possible at all or if CATIA wont allow it?
In my dream scenario I would like the to be able to change the sets of points (stored in diiferent tabs in Excel) in the same manner as when you change Parameters using the Design Table function. Do you know what I mean? I guess will have to work on this for a while... =)
Regards, John
Milton Hartung
COE Administrator
I am new on this forum and I could really used the macros you are talking about but I don't know where to find them in the website.
Thanks,
Javques
Mike Despenza
Milton,
Great macro, I started with the original script from awhile ago on my old system. Then I upgraded to the latest and greatest with the GUI, and my 64 machine. Export only gives me 0,0,0, but I need the import function. The first three times I ran the import function (from Excel and a .txt) it worked great. The last time it worked I used a custom delimiter, now i get this error before the GUI even "pops-up":
"Run-time error '2110':
Can't move focus to the control because it is invisible, not enabled, or of a type that does not accept the focus."
Debug jumps right to the Private Sub optExplicitDelimiter (ln63) but I have no idea how to fix it, or build in exception handling.
Thanks in advance for any help you can offer.
MD
Milton Hartung
What did you use for the delimiter? Perhaps I didn't test enough possibilities to find one that broke it. In the mean time, can you comment out line 62:
txtExplicitDelimiter.SetFocus
and/or clear the related registry keys at:
HKEY_CURRENT_USER\Software\VB and VBA Program Settings\CATIAPoints\Import\
That sounds like it is causing the problem, but I can't think why because I didn't think that sub should be calling unless you click the checkbox. I will look at it closer when I get a minute, and post any updates if I find a change is needed.
As for the x64 issue, I really don't have any ideas what is different in the x64 code that causes the 0,0,0 issue. Like I said before, I can run the export on x64 machine with x86 CATIA code installed with no issues.
Mike Despenza
For future reference should the input be vbTab or \t?
I also noticed it loading the value of the reg key when the checkbox is clicked, despite what's been typed in the box.
Works like a charm again, I especially like the Excel input feature. Thanks.
MD
COE Administrator
It seems that the import macro works fine but I would like to know how the excel spreadsheet used to export data from has to be filled in. Do you have a template of an excel spreadsheet which works? If yes it would be very nice of you to forward it to me.
cheers
Jacques
Milton Hartung
COE Administrator
when i try to import data from an excel spreadsheet which is made of 3 columns (X, Y and Z), I get this error:
"
Invalid Point encountered. Continue?
Contents of invalid point file line:
##### (different symbols)
Expected delimiter: .
"
Do you know how to avoid this error?
Thanks
Jacques
Milton Hartung
If for some reason you cannot use the Import From Excel option, you could save your Excel document as some kind of delimited text file, and then import it.
COE Administrator
The macro works perfectly well and saved me a lot of time in my work.
I still have something to ask you. I could really use the same function JIGGA was talking about, i.e. a function where the imported points overwrite the ones already in the part so that they can be manipulated from an Excel spreadsheet. I have tried to create a function at the level of the creation loop in your macro (around the Set newpoint function) but I am a beginner in VBA, and even more in VBA for Catia so I could really use a little help on this one...
Thanks again
Jacques
Juergen Bittner
Hello everybody
I have to import in Catia V5R17 point coordinates form a text
file.
In my TXT file I have the XYZ coordinates, see attachment.
I followed the steps from LUENYAR see below:
1. Within CATIA, click Tools -> Macros->Macros.
2. Click the 'Macro libraries' button.
3. Under 'Library type:' choose 'VBA Projects', then click the
'Create new library' button. Enter the path and file name you want
here.
4. Close the 'Macro Libraries' window.
5. Within CATIA, click Tools->Macros->VB Editor.
6. Select the new Library from the tree on the left side, then
click File->Import File.
7. Set 'Files of type' to All *.*, and browse and select to where
you saved the .txt files from me. Pick one and repeat 7 for the
other.
8. Lastly, before exiting VB Editor, click Tools->References.
Find 'Microsoft Excel 11.0 Object library' and check it. If it is
Excel 9 or 10 or 12 or something, it should still work fine. 11.0
is just what is with Office 2003.
9. Save the VB Project and close the Editor.
10. Now in Tools->Macros you can run these modules you just
imported. If you have CATScript and Catvbs macros that you need as
well, simply change the 'Current macro library or document' to the
Macro folder you had defined before.
The result was this error message:
COMPILE ERROR
SYNTAX ERROR (and all the xyz coordinates are shown in red)
I think the issue is with the VBA script. Could somebody show me how to write this script the right way with maybe a screen shot, etc.
Please help.
Thank you all,
Juergen
Juergen Bittner
Hello Milton,
When I follow your steps I get always a CATVBA with all the coordinates shown in red.
I think the problem is how the scriped is written (see the command I made just a few minutes ago).
Would you be so nice to help me out?
Thank you,
Juergen
Milton Hartung
So, this is my idea for accepting TAB and pretty much any character or string you might be using as a delimiter. The combo box has choices for TAB which uses vbTab, and SPACE which is just a single space, and comma and semi. Then you can also type a character or string as well. I quickly tested it with '~~~' and '^$#' which both work fine, so you could use probably anything that isn't used to represent the values themselves [numbers, single dashes, etc].
Juergen Bittner
Hello Milton,
you are my hero!!!
Your macro is great and it worked best with a Excel file, I imported up to 15000 points with no problems.
Regards,
Juergen
Tolga Guzel
How is the macro downloaded? I couldn't find in this topic.
Thanks a lot
Haridas PT
See the last line for the reply dated 03 Feb 2009 07:46 AM. You will find a .zip file. ight click and save the file.
Tony Nhu
LUENYAR:
May I have a copy of this VBA project to export points from Catia?
COE Administrator
I have installed the macro librairy posted on 03 Feb 2009 07:46 AM. (12332307833.zip)
I can export points to a txt file... it works perfectly, but I can't import points. I get the following error:
"Macros raised an unexpected error -2147467259 (Method 'Search' of object 'Selection' failed)."
I get the same message on two different pc (one with Excel 2007 and the other one with Excel2003)
Can someone help me out?
Thanks,
Dom
David Haag
Hi Milton,
I have also installed the VBA Project in my CATIA V5-R18 in Windows XP 32 OS.
Some of the macros work like the rename elements, but when I choose the import or export points macros nothing happens, no pallet, no exported point list.
Is there something I have missed.
Any input would be a great help.
Thanks,
David
Krzysztof Bialek
I have the same problem as DavidHaag has.
Windows XP Pro, CATIA 5.18 SP5, VBA.msi installed, Microsoft Excel 12.0 Object Library selected
/Krz
Krzysztof Bialek
I have more info about the problem.
If I start macro in normal way (Alt+F8, select ExportPoints, Run) then nothing happen.
But if I Choose ExportPoints then Edit and run it from VB editor then... it works.
Then the problem is that if I export to Excel file then the coordinates are 1000x bigger. If I use 1000 unit in the form then the coordinates are 1000x smaller then real.
But if I export to txt then coordinates are OK.
/Krz
Pawel Dobrowolski
If macro interpret . as dot point (American stanadard) and you use European standard , as dot point, you can get wrong number.
Comma , is used to define thousands in American standard.
If you use for example Polish regional settings, you can try to change them to American or British and check macro.
This can help. However, I'm not sure because i didn't looked in code.
Note that Excel is using Windows regional settings to define numbers.
Pawel,
Krzysztof Bialek
But problem with running the script in normal way still remains. It's working in 5.16 but not in 5.18.
Even if I start it from VB editor and use export to Excel then after script adds coordinates into Excel I get erro message in VB editor:
Run time error '5':
Invalid procedure call or argument
and if I click on "Debug" it shows that the problem is in line number 323:
AppActivate "CATIA"
What can it be?
(I have English Windows XP 32bits)
/Krz
Ian Spiller
I have a very large point file ( Roughly 300,000 points) in a .txt file. Units are in standard 1 inch, and they are set out to 6 decimal places.
Is the decimal place definition causing the error or the mass number of points?
Milton Hartung
This was due to an oversight on my part. The counter variable in the macro was declared as Integer. I've changed it to Double, so now you should be able to import as many points as CATIA and your workstation can handle. This is the only change from the last posting. Enjoy!
We're using MSO 2007 now by the way, so you may also have to change the References Excel xx.0 entry.
COE Administrator
Hi Buddy ,
Your works looks fantastic but I am not able to see your attachments. Can you make the links visible? I am a beginner and totally lost in this conversation. Everyone is talking about the macros but I don't find them anywhere. Please help. And how can I install them?
Thanks
Nile
Andy Southern
This Macro is great! everyone in the office looked at me after I imported a couple of hundred points and exclaimed my delight!
Is there a way to import the points and keep them referencing the original CSV/Tab text files?
Thanks,
-Andy
Hrishikesh Mandyam
I just found the vba projects and added them to my library. I want to know if this works for ASCII files? I have a file which potentially contains more than a 100000 points data and would like to import it. Please guide.
Thanks loads.
Rishi, on Catia V5 R18 WinXP 32/ on Catia V5 R19 Win Vista 32
Samarinder Singh
Hi Milton,
The macro is working fine for me as long I use text file. However,
it is giving me some errors when I try to export the points in
Excel file format.
R19sp4 win XP pro 32bit MSO2007
few questions:
Do I have to have excel open at time of running the macro?
Do I have to have a blank file saved from Excel prior to run this
macro?
Do I have make that change inside the macro in order to run with MSO 2007?
Thanks
Milton Hartung
@HMandyam: The most recent macro should be able to import as many points as your workstation can handle. It will run a very long time I think, but it theoretically should complete.
@Samarinder: The Export dialog specifies 'An open Excel sheet'. You need to have Excel running and you will select a range in the Excel sheet. You are able to select multiple non-adjacent ranges, even on separate pages. Also, each person using the macros may have to change their reference library setting.
Roger Leach
We are running XP Pro x64 with x64 CATIA R18SP7 and the macro successfully puts values into Excel, but all these values are ZERO (0). The text file output is also ZEROs (0).
Also, if we choose the axis option we we get the attached error.
Are there any settings that are different for x64?
Thanks,
Roger
James Woodard
I realize this tool already does a lot and looks great but I run into something else all the time and was wondering about getting it automated. Many projects that I am involved with requires the coordinates of a large number of points within a part file to be updated with values from an excel spreadsheet. I was wondering if something like that would be hard to implement into this tool? Thanks.
Samuel Lindholm
Sorry, I wasn't very clear I think. These MUST be imported into a VBA project. To my knowledge this limits you to Windows-based I'm pretty sure. Anyway here are the steps that should hopefully lead to everyone's success.
1. Within CATIA, click Tools -> Macros->Macros.
2. Click the 'Macro libraries' button.
3. Under 'Library type:' choose 'VBA Projects', then click the 'Create new library' button. Enter the path and file name you want here.
4. Close the 'Macro Libraries' window.
5. Within CATIA, click Tools->Macros->VB Editor.
6. Select the new Library from the tree on the left side, then click File->Import File.
7. Set 'Files of type' to All *.*, and browse and select to where you saved the .txt files from me. Pick one and repeat 7 for the other.
8. Lastly, before exiting VB Editor, click Tools->References. Find 'Microsoft Excel 11.0 Object library' and check it. If it is Excel 9 or 10 or 12 or something, it should still work fine. 11.0 is just what is with Office 2003.
9. Save the VB Project and close the Editor.
10. Now in Tools->Macros you can run these modules you just imported. If you have CATScript and Catvbs macros that you need as well, simply change the 'Current macro library or document' to the Macro folder you had defined before.
Look back over my original post for some usage ideas. And let me know if you have other questions.
Shailesh Sathe
Hi LUENYAR,
Can you please send me this macro. my id is [login to unmask email].
I am new to this forum and i need this maco to import sthje points in CATIA V5.
I am hoping to get help from you.
Shailesh
COE Administrator
What I would like to do is to take a list of points that are labeled into sets to create polylines from these sets of points.
For example, this is part of my input:
240,40,750,0
240,20,750,0
240,20,140,0
240,40,140,0
240,40,750,0
241,40,-750,0
241,60,-750,0
241,60,-140,0
241,40,-140,0
241,40,-750,0
This gives me 5 points labeled "240" and 5 labeled "241". What function calls would I use, which I can add to this macro, to create polylines from this type of input? I would greatly appreciate any direction as I try to make sense of the CATIA API. By the way: is there a good CATIA API reference out there?
Best,
Matthew
COE Administrator
http://www.coe.org/Portals/0/NTForums_Attach/15672088363.zip
Best,
Matthew
Shailesh Sathe
Thanks a lot for that.
One more request i have. Could you send me the .txt files you wrote about in the post?
I am getting error when i click import points from excel
The error is "cant find project library". I am very poor in Visual basic so i m not getting what it is.
Thanks for the help in advance.
Shailesh
Brian Phelps
I don't see where this vba is available. Where can I find it?
Milton Hartung
We don't really have any public website, but I had this posted where it can at least be downloaded Hopefully this makes it easier to find the latest Macro file.
Roger Leach
Does this one run on XP x64 with 64-Bit CATIA?
Milton Hartung
Unless they've changed the 64-bit CATIA code or API or something, then no. As far as I can tell, no one has had luck getting point coordinates from the 64-bit CATIA. It works for me on Vista 64 running 32-bit CATIA.
Mike Berry
Have you tried using the measurable object to get the point coords instead of the GetCoordinates method on the point? Measurable method works on 64bit CATIA...
Example...
Dim varCoords(2) As Variant
Set objSPAWorkbench = objPart.Parent.GetWorkbench("SPAWorkbench")
Set objPtRef = objPart.CreateReferenceFromObject(objPt)
Set objMeasurable = objSPAWorkbench.GetMeasurable(objPtRef)
objMeasurable.GetPoint varCoords
MsgBox Join(varCoords, ", ")
-Mike
Milton Hartung
Mike Berry
Also, I just downloaded your vba project - nice work!
-Mike
Daniel Cernada
I'm looking for a macro to export catia points (pasted as result) to excel, I think I'm in the right post,
but, How can I download your macro??,
It has a link to another website with a password, do you know what the password is?
Thank you
Daniel
Knight Zwy
need your help.
Jack Rowe
I can run this program and it works but is there to run this from within a product and run it on all of the parts. Note I am a newbie.
Milton Hartung
COE Administrator
Hi,I was just trying to make it work but in some step I am probably wrong...When I complete the 6th step I have a messsage 'this file cannot be loaded'...I had extracted it on my desktop as a catvba file and not as a text...I am using Windows Vista as operating system on my Laptop and I can't change it into text,I only opened it with the notepad and the result is the same...Can I have some help here???
Antonis
Andrew Armstrong
Open the VB Editor (ALT+F11)
Choose File->Macro Libraries...
Change the Library type: to VBA projects
Click Add existing library...
Choose the file from your desktop, and it should appear in your Current libraries
Close the Macro libraries box, and the project should now be in the tree in the VB editor
To run, click ALT+F8 in CATIA, and run the proper module
Hope this helps!
Andrew Armstrong
COE Administrator
Andrew thanks a lot,I had already done it before your post,but thanks anyway m8!
The other thing is that I can't export the points...This sub-program shows a message 'set the geometry of points' or something like this....WHAT THE HECK does that mean?I set the drafting geometry at the left of the screen but sends me back 'No points inlcuded' or something like this..Can anyone write doen the process and what do I have to select?????
Antonis G. Stamopoulos
COE Administrator
I've never done anything like this before, but eventually got it to run once I followed your instructions exactly, rather than thinking for myself.
Thanks
Geoff
COE Administrator
Milton Hartung
I finally got the time to make the Export functions work with the 64-bit CATIA code. I only ran a couple of tests on a 64-bit machine, but it seemed to work great. Thank yous to Mike Berry for the Measurable suggestion, that is what I employed to fix it. Enjoy!
Maryam Khelghati
I want to import some points from excel to catia.I read your comments,but I can not download PointsMacros.zip file.the error is that I dont have permission! would you please send it to me via E-mail?? my E-mail adsress is: [login to unmask email]
Thanks a lot
Maryam
Luke Huckin
I would like to use your macro to import a large amount of points for a reverse engineering work package I'm performing.
Could you email me the marcro or put it into your dropbox again.
Many thanks
Luke
[login to unmask email]
Lim Kenta
I am download your catvba. add in in a macro and try to click run. it mentioned "run time error. tye mismatch.
may i know why?
furthermore,i follow all your instruction
"7. Set 'Files of type' to All *.*, and browse and select to where you saved the .txt files from me. Pick one and repeat 7 for the other."
what is the txt file?i cant search.thanks
looking forward to your reply
Xia Salud
I got it ! Many thanks for LUENYAR and Luke, and i will try it again !
Andrew Moro
Whenever I try to run the macro I get the following errors:
“Macros (line 0) raised an unexpected error 429 (ActiveX component can’t create object)”
“Macros (line 0) raised an unexpected error 91 (object variable or with block variable not set)”
Do you have any insight as to how to fix these problems?
I am running this on CATIA V5R18 with Windows XP SP3.
Thank you so much for any help you can provide.
~Andrew
Little Cthulhu
Try following script - http://www.catiav5forum.de/wbb3/wbb/index.php?page=Thread&threadID=4273 (be sure to get it's latest version)
COE Administrator
Great macro! I was just wondering is it possible for me to export points from one face at a time instead of exporting the full range of points from the part? I am really stuck as to how I would go about doing this
Milton Hartung
Ni Wayne
Joe Hayden
I'm trying to import point coordinates for airfoil sections into CATIA and this script looks like it's the answer to all my problems, well maybe not all but . . . I believe I've followed your instructions to the letter but still can't get the macro to run. Obviously I'm missing something important!
At the very beginning of this post you say to rename the .txt file to .bas but when I unzip the folder after downloading the only thing in there is a .catvb file, so I'm not sure which file I need to rename.
When I try to run ImportPoints from the Macro window nothing happens. If I try to run one of the Modules that gets created after importing a .txt file with the point coordinates I get an error box: "The script entry point could not be found. Define a "CATMain" procedure which will be the entry point of the script."
I am running CATIA V5R18 on Windows XP64 SP2. Thanks for your help!
-Joe
Little Cthulhu
Take a look 5 posts above:
"Try following script - http://www.catiav5forum.de/wbb3/wbb/index.php?page=Thread&threadID=4273 (be sure to get it's latest version)"
bharath17 bharath
hi
i dont know much about vba but with help of my friends i was able to extract points from catia to excel,
and also from excel to catia.
i have isolated series of points i want to make them coordinates.
i want to make the points as coordinates without creating new points as they are in link with the curves.
can u please suggest any solution for this.
thanks for ur previous msgs which help me alot
bharath17 bharath[maxindra] @ Sep 04, 2012 - 10:57 PM (Asia/Calcutta)
Little Cthulhu
The only solution I found is with the help of WinAPI.
Script below should be run as catvba project (not as CATScript).
bharath17 bharath
Thanks a lot, its working and this was very helpful for me.
bharath17 bharath[maxindra] @ Jan 27, 2012 - 02:04 PM (Asia/Calcutta)
Richard Campbell
I am aunable to get the macros working in V5 R20, any help is greatly appreciated.
When I run it it returns Compile error: Can't find project or library. After you hit enter or select OK it highlights "Dim catDocument As PartDocument" in blue and "Public Sub ExportToFile(ByVal dbScale As Double, ByVal strFilename As String, ByVal tfUseNames As Boolean, ByVal tfUseAxis As Boolean, ByVal intPrecision As Integer, ByVal strSeparator As String)" in yellow
I'm not sure where to go from here...
Little Cthulhu
Are you trying to run it from excel? If so, in VBA editor go to Tools-References menu and check all CATIA V5 libraries.
Richard Chambers
Sorry for opening an old thread, but does anyone have an updated Macro for R2013 to export points from a geometrical set and place them in Excel?
Thank you,
Richard
Richard Chambers
This is what I have so far - but I get the "Type mismatch: 'point.GetCoordinates' error on line: 37
Sub CATMain()
CATIA.ActiveDocument.Selection.Search
"CATGmoSearch.Point,all"
StartEXCEL
ExportPoint
'objGEXCELSh.Application.ActiveWorkbook.SaveAs (ExcelFolder
&
Left(CATIA.ActiveDocument.Name,Len(CATIA.ActiveDocument.Name)-8)
&
".xls")
'objGEXCELSh.Application.ActiveWorkbook.Close
End Sub
'******************************************************************************
Sub StartEXCEL()
'******************************************************************************
Err.Clear
On Error Resume Next
Set objGEXCELapp = GetObject
(,"EXCEL.Application")
If Err.Number <> 0 Then
Err.Clear
Set objGEXCELapp = CreateObject
("EXCEL.Application")
End If
objGEXCELapp.Application.Visible = TRUE
Set objGEXCELwkBks = objGEXCELapp.Application.WorkBooks
Set objGEXCELwkBk = objGEXCELwkBks.Add
Set objGEXCELwkShs = objGEXCELwkBk.Worksheets(1)
Set objGEXCELSh = objGEXCELwkBk.Sheets (1)
objGEXCELSh.Cells (1,"A") = "Name"
objGEXCELSh.Cells (1,"B") = "X"
objGEXCELSh.Cells (1,"C") = "Y"
objGEXCELSh.Cells (1,"D") = "Z"
End Sub
'******************************************************************************
Sub ExportPoint()
'******************************************************************************
For i = 1 To CATIA.ActiveDocument.Selection.Count
Set selection = CATIA.ActiveDocument.Selection
Set element = selection.Item(i)
Set point = element.value
'Write PointData to Excel Sheet
point.GetCoordinates(coords)
objGEXCELSh.Cells (i+1,"A") = point.name
objGEXCELSh.Cells (i+1,"B") = coords(0)
objGEXCELSh.Cells (i+1,"C") = coords(1)
objGEXCELSh.Cells (i+1,"D") = coords(2)
Next
End Sub
