Macro to extract dimensions related to Instantiate 2D symbol in catia drawing & export them in e
Macro to extract dimensions related to Instantiate 2D symbol in catia drawing & export them in e
(OP)
Hi friends,
Am new to this forum...
i heard about this forum through my frnds.
happy to be part of this forum.
I need a macro very urgently to extract the dimensions near to the Instantiate 2D component symbols in CatiaV5 drawing and save/export those dimensions to an excell file.
am using Catia V5 R19....
Please do the needful...
Am new to this forum...
i heard about this forum through my frnds.
happy to be part of this forum.
I need a macro very urgently to extract the dimensions near to the Instantiate 2D component symbols in CatiaV5 drawing and save/export those dimensions to an excell file.
am using Catia V5 R19....
Please do the needful...
RE: Macro to extract dimensions related to Instantiate 2D symbol in catia drawing & export them in e
Are you referring to the dimensions that can be found by right-clicking the component instance in the tree and clicking on Properties and looking under the 2D Component Instance tab? See attached image for clarification.
If yes, then you can use the following code. I will need you to respond and clarify what sheet and view the instance is located on. Also, where and under what name do you want the excel file to be saved? Right now, this code simply outputs it via a message box.
CODE --> vba
Regards,
Drew Mumaw
http://www.drewmumaw.com/
http://www.textsketcher.com/
RE: Macro to extract dimensions related to Instantiate 2D symbol in catia drawing & export them in e
Thank you so much for your reply.
Sorry for not mentioned my requirements clearly in my previous thread.
My requirements are,I need a Macro which can export the list of dimensions containing the symbol adjacent to that & save as an excel (or) csv file.
The excel (or) csv file has to be saved in Drawing name and in the folder which contains the respective Catia V5 drawing.
Please see the attached image for clarification...
RE: Macro to extract dimensions related to Instantiate 2D symbol in catia drawing & export them in e
I understand. So you want to export to a .csv file with all of the dimensions that have a specific symbol next to them, correct? If yes, then my answer is, this cannot be done as you would like unless there's something else (possibly the naming of the dimensions?) that differentiates the dimensions with the symbols from the dimensions without the symbols. It's possible to export all of the dimensions on Sheet.1, but from your screen grab, I don't see how the macro would be able to tell which dims have a symbol associated and which ones don't. There would have to be some manual work after the fact. Or, like I mentioned, if the dimensions with the symbols have something special in their name such as "dimwithsymbol" then the macro could just export those. For example, a dimension with a symbol could be named "Dimension.4.dimwithsymbol" and the script would sort through all of the dims and include this one for export since it had the "dimwithsymbol" string in the name.
I put this macro together quickly to show you how to loop through all of the dims in each of the views on "Sheet.1". It just shows them in a message box pop up one at a time. It doesn't process angles correctly and doesn't have a way of telling dims with symbols apart from the dims without symbols:
CODE --> vba
Regards,
Drew Mumaw
http://www.drewmumaw.com/
http://www.textsketcher.com/
RE: Macro to extract dimensions related to Instantiate 2D symbol in catia drawing & export them in e
Thanks for your time and reply.
When I try to run your code to see the result. I get an error as ‘expected end of statement’.
Please see the attached image for clarification.
RE: Macro to extract dimensions related to Instantiate 2D symbol in catia drawing & export them in e
The screen grab which I have attached in my previous thread was just an example. My Drawing may contain ‘N’ number of views (see the ‘Specification Tree’ for the drawing - REV003 in the image attached in my previous thread) and ‘N’ number of dimensions with the symbols and without the symbols in the views.
I dont understand what do you mean by dimension with a symbol could be named "Dimension.4.dimwithsymbol".Did you mean that each dimension with symbol should have an unique TEXT before?
Is it possible to sort and export the dimensions based on the Name given for the ‘Instantiate 2D component” symbol in the Drawing sheet? (For example TRIANGLE_3 (or) DIAMOND) ( Refer attached image)
And I don't want any message box pop up to show the dimensions in the views, thats not my requirement.
RE: Macro to extract dimensions related to Instantiate 2D symbol in catia drawing & export them in e
@ friendlyamu - be so kind and post what you tried to code to solve your requirements, it will be much easier for others to help you. If you want to learn more about programming first you should try something, don't expect for others to solve your problems completely, what you want is not so easy to be done (and by the way, it can be achieved only if your drawing was done in a specific way, meaning dimension has a link with the ditto, otherwise is to complicated and is wasting developer's time).
Generally speaking, when someone develop a macro for his company (or for himself), is taking in account how often it will be used and how big it will be the benefits using the macro comparing with time to develop that macro.
Regards
Fernando
https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...
RE: Macro to extract dimensions related to Instantiate 2D symbol in catia drawing & export them in e
The code I uploaded was labeled "vba". According to your screen grab 2Que, it looks like you were trying to test it in a vbscript editor with different syntax. That could possibly be causing the error you mentioned. To test it in CATIA's built in vba editor hit Alt+F11 or simply go to Tools > Macros > Visual Basic Editor. Create a new catvba file if one doesn't already exist. In the left hand side, right-click on the catvba file and insert a new module. See this image. You can put your code in here and run it by clicking the rightward facing arrow that looks like a play button.
Also, I'm aware that the code I uploaded did not solve your requirements, it was simply a starting off point for getting the logic structure together for your eventual solution - as I mentioned in my first post:
Right now I simply use message boxes to view what could be output to a .csv - since I'm 100% sure that exporting to a .csv is possible I didn't waste any time including it in the logic. In other words, we can add that requirement last.
Thanks for the screen grabs. They are very helpful.
No. The name of the "Instantiate 2Dcomponent" is not relevant from an automation standpoint. We need a way to determine which dimensions have a symbol next to them and which ones don't.
Yes. If it's feasible from your side of things - something along those lines would work. See this image as just an example of how the dimensions with the symbol could be named. If they all had some string of text in their name, such as "dimwithsymbol" or whatever else, then the macro would be able to know which dimensions need to be exported and which ones don't.
Regards,
Drew Mumaw
http://www.drewmumaw.com/
http://www.textsketcher.com/
RE: Macro to extract dimensions related to Instantiate 2D symbol in catia drawing & export them in e
RE: Macro to extract dimensions related to Instantiate 2D symbol in catia drawing & export them in e
This code will write your selected dimension values to a .csv file on the desktop (you need to change the file path in the code to reference your desktop location - not mine). See here for an example of the output.
CODE --> vba
Regards,
Drew Mumaw
http://www.drewmumaw.com/
http://www.textsketcher.com/
RE: Macro to extract dimensions related to Instantiate 2D symbol in catia drawing & export them in e
The code works great. Thanks a lot for your help.
This code exports the selected dimension to the Excel file superbly.
RE: Macro to extract dimensions related to Instantiate 2D symbol in catia drawing & export them in e
RE: Macro to extract dimensions related to Instantiate 2D symbol in catia drawing & export them in e
The code below will also export the tolerance values. I'm not sure about the geometrical tolerances.
CODE --> vba
Regards,
Drew Mumaw
http://www.drewmumaw.com/
http://www.textsketcher.com/
RE: Macro to extract dimensions related to Instantiate 2D symbol in catia drawing & export them in e
Geometrical tolerances were not exposed to automation.
There is no API of any kind to access, using object browser also wont yield any results.
Tried some times back with no success
Regards,
Maddy
The willingness to share knowledge does not make one charitable; it makes one self-reliant to know more.
Modified - Courtesy of Robert Brault
RE: Macro to extract dimensions related to Instantiate 2D symbol in catia drawing & export them in e
@Maddy02 : Thank a lot for your valuable information.
RE: Macro to extract dimensions related to Instantiate 2D symbol in catia drawing & export them in e
This should take care of the tolerance values and radians:
CODE --> vba
Regards,
Drew Mumaw
http://www.drewmumaw.com/
http://www.textsketcher.com/
RE: Macro to extract dimensions related to Instantiate 2D symbol in catia drawing & export them in e
My requirement is also same that of what friendlyamu posted.But i want to extract some more details to the csv file.
Is it possible to extract the Balloon numbers along with the corresponding dimensions in the extracted csv file?
Please find the image for better understanding.
Thanks in advance.
Regards,
D.Balaji
RE: Macro to extract dimensions related to Instantiate 2D symbol in catia drawing & export them in e
RE: Macro to extract dimensions related to Instantiate 2D symbol in catia drawing & export them in e
I looked, but couldn't find anything in the API for being able to do this. If you put the chamfer dimension in the format angle x distance then it will export the angle, but not the distance. Apparently, you can only access the first value in a chamfer dimension. This seems odd, so I'll keep looking through the API, but I tried several things already and couldn't find a way to access it. Maybe someone else will post a way that this can be done? But from my initial web searches and other threads it seems like automation in the drafting workbench is very restrictive.
@DBalaji89
Yes. It is possible to extract the balloon numbers. However, there must be something for the script to be able to know that the balloon is related to the dimension. Either the balloon should have a positional link (see this) with it's corresponding dimension, or the name of the dimension and the balloon should have a string in both that relates the two. For example, the name of the dimension could be DimensionWithBalloon.5 and the name of the name of the balloon could be Balloon.5. That way the script would know to look for a dimension and a balloon with the name Balloon.5 in them so that it could export them on the same line in the .csv file. I would recommend doing it with the positional link.
Regards,
Drew Mumaw
http://www.drewmumaw.com/
http://www.textsketcher.com/
RE: Macro to extract dimensions related to Instantiate 2D symbol in catia drawing & export them in e
First of all i would like to say thanks for your reply.
To be frank, am not a programmer and I don't have any knowledge in writing code in VB.I just suggested to enhance Friendlyamu's requirement.
As per your last code it exports only selected set of dimensions to csv file.In case if the selected set of dimensions(selected from different VIEWS in the drawing) contain a similar dimensions it would be difficult to identify in the csv file that which dimension from which VIEW (or) ZONE in the drawing is exported.
So I requested, Is it possible to extract the Balloon numbers along with the corresponding dimensions in the extracted csv file?
It will be great if you can post the code that can extract Balloon numbers(having positional link with the dimension) along with the dimensions.
Thanks in advance.
Regards,
D.Balaji
RE: Macro to extract dimensions related to Instantiate 2D symbol in catia drawing & export them in e
With regards to DBalaji89's suggestion, it is definitely necessary to have some way to identify the dimension extracted in the .csv file. This way of giving balloon number & extracting it along with the corresponding dimension in the same line in the .csv is highly appreciated.Also it would be very helpful to accomplish my task if you can post the code that exports balloon numbers along with the dimension.
RE: Macro to extract dimensions related to Instantiate 2D symbol in catia drawing & export them in e
If you want the script to output the corresponding view that the dimension is located within use this:
CODE --> vba
Regards,
Drew Mumaw
http://www.drewmumaw.com/
http://www.textsketcher.com/
RE: Macro to extract dimensions related to Instantiate 2D symbol in catia drawing & export them in e
I just saw your response after my browser refreshed. Hopefully the code I just posted for exporting the view name will suffice for locating the dimension.
Also, with regards to this:
Yes. It is possible to fix this, but all of your chamfer dimensions must be in the same format - either angle x distance or distance x angle. They can't be a mix of the two because there's no way that I've found in the API to grab the second dimension. So either it will export the angle (in degrees) if it's in the format angle x distance or the distance if it's in the format distance x angle.
Regards,
Drew Mumaw
http://www.drewmumaw.com/
http://www.textsketcher.com/
RE: Macro to extract dimensions related to Instantiate 2D symbol in catia drawing & export them in e
RE: Macro to extract dimensions related to Instantiate 2D symbol in catia drawing & export them in e
1. It's possible to extract the associated balloons, but it would require a loop to get all of the balloon's associated elements and then check to see if the associated element's dimension is getting exported. If it is, then it would also export that balloon's value. Long story short, it requires a lot more code, but would include the AssociateElement property:
CODE --> vba
2. If you have all chamfers in the format angle x distance then give this code a try. It should export the angle in degrees instead of radians.
CODE --> vba
Regards,
Drew Mumaw
http://www.drewmumaw.com/
http://www.textsketcher.com/
RE: Macro to extract dimensions related to Instantiate 2D symbol in catia drawing & export them in e
RE: Macro to extract dimensions related to Instantiate 2D symbol in catia drawing & export them in e
Great work, I found this macro. But we have lot of problems with VBA, if possible could you translate it to catscript or catvbs format with balloon function?
regards,
Catia user/looser :)
RE: Macro to extract dimensions related to Instantiate 2D symbol in catia drawing & export them in e
May I ask refering to my question http://www.eng-tips.com/viewthread.cfm?qid=358168 , is the same procedure possible to get the data to be edited in Excel from a partbody instead of a drawing ?
what are the apropriate modifications ?
Thank you very much