×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Catia Macro to automatically measure spline

Catia Macro to automatically measure spline

Catia Macro to automatically measure spline

(OP)
Good morning all !

So I made some formula (with the help of you guys) to measure some splines.It works perfectly but now I need to somehow automate the process.Not really knowing programming and stuff I just pushed the record macro button and all seemed OK. I just need to fill in the Part Description field with this formula:

"L="+ToString((1+int(((MeasureEdge.1\Length/1mm)+15/100*(MeasureEdge.1\Length/1mm))/50))*50)+"mm"

With the script that Catia has recorded, the output is like this

Language="VBSCRIPT"

Sub CATMain()

Dim partDocument1 As Document
Set partDocument1 = CATIA.ActiveDocument

Dim part1 As Part
Set part1 = partDocument1.Part

Dim relations1 As Relations
Set relations1 = part1.Relations

Dim parameters1 As Parameters
Set parameters1 = part1.Parameters

Dim parameter1 As Parameter
Set parameter1 = parameters1.Item("1510005-L1-504\Product Description")

Dim formula1 As Formula
Set formula1 = relations1.CreateFormula("Formula.2", "", parameter1, "" & """" & "L=" & """" & "+ToString((1+int(((MeasureEdge.2\Length/1mm)+15/100*(MeasureEdge.2\Length/1mm))/50))*50)+" & """" & "mm" & """" & "")

formula1.Rename "Formula.2"

End Sub


The error is in line 18, I think because this line contains the name of the part in which the script was recorded.

How can I get rid of this error and make the macro working for arbitrary parts ?

Have a nice weekend,

Costin

Best regards,
Costin Ruja

RE: Catia Macro to automatically measure spline

(OP)
And I also saw that the macro doesn't record the operation of measuring the spline. Is this some kind of a bug ?

Best regards,
Costin Ruja

RE: Catia Macro to automatically measure spline

can you explain the big picture of what you're trying to do?

the script should create a parameter based on the length of a spline? How many spline you want to measure. why do you need this parameter?

I'm asking just to make sure we go in the right direction...

you script does use a measureedge, not sure this is the best solution....

Eric N.
indocti discant et ament meminisse periti

RE: Catia Macro to automatically measure spline

Hi

Try to avoid specific names, this is what is happening when you record macro. On recorded macro, you have to eliminate those parts of the code which is referring to specific names or specific instances in a part. You can force user to select what you want (eventually rename with a specific name if you need that) and then refer to that selection.

Indeed, more details will help us to understand what you want, Eric is right.

Regards
Fernando

https://picasaweb.google.com/102257836106335725208 - Romania
https://picasaweb.google.com/103462806772634246699... - EU

RE: Catia Macro to automatically measure spline

(OP)
Good morning !

In principle , I have some splines that represent electrical conductors (no harness license here, just GSD). Finally, there should be some kind of length measured so the worker in the factory knows how to cut those wires. By trial and error over the years, we managed to translate this in a formula, the spline measured in Catia plus 15%, and rounded upwards to 50mm.

You can find below a picture


The blue and the yellow wires are separate parts, each containing just a spline. The goal is to retrieve this length information in the drawing BOM, so when I modify the model or modify the path of the conductor, this also reflects in the BOM.

This works ok doing it manually with every spline part, just masuring the spline with "measure item", and then going to formula editor and entering the formula by hand.

I want to automate this and just open the spline part in a separate window and run a macro that measures the spline, applies the formula, and puts this information in the "product description" field, like in the image below:



I would appeciate the help.

Thank you !

Costin Ruja

Best regards,
Costin Ruja

RE: Catia Macro to automatically measure spline

powa copy !

I have the feeling a nice powercopy could do the job. with reaction so if length change, description would be updated.

input could be geomset, part or curve as you said only one curve in part so a Part->Query would find the curve...

you can create length parameter using length(curve) that would make it associative, you can include also your magic in the formula or create a second length parameter link with the first one so you could have real length and BOM length as parameters.

then a reaction based on geometry updated that would update Description based on BOM length parameter.

I would use this as once it is instantiated in the part, any update of the part would not require any action as it would update by itself.

you might need some KWE/KWA license don't know exactly which one to create the reaction.

Eric N.
indocti discant et ament meminisse periti

RE: Catia Macro to automatically measure spline

"I have some splines that represent electrical conductors (no harness license here, just GSD)."

RE: Catia Macro to automatically measure spline

(OP)
Oooookkk,

So I managed to measure the spline correctly with "length(`Geometrical Set.1\Spline.1')" and not with the measure tool.

How do I manage to make the script to not refer to the current part ?

Set parameter1 = parameters1.Item("1510005-L1-504\Product Description")

So in theory i will have to get rid of names and make something general.
Costin

Best regards,
Costin Ruja

RE: Catia Macro to automatically measure spline

If you want to get the name of a selection (first one, lets suppose you push the user to select something) you can use

MySel.item(1).value.name

Lets say you are in a product and want to find the name of a selected part....be aware that you need something else depending how you are working (file system, PDM, v5 , v6....)

CODE --> CATScript

Sub CATMain()
Dim InputObjectType(0)

Set MySel = Catia.Activedocument.Selection
 InputObjectType(0)="Part"
 Status=MySel.SelectElement2 (InputObjectType, "Select any Object, you will get just Part",true)
 if (Status = "Cancel") or( status="Undo") then
    MySel.clear
 Else
     MsgBox MySel.item(1).value.name
End IF

MySel.clear

End Sub 

Regards
Fernando

https://picasaweb.google.com/102257836106335725208 - Romania
https://picasaweb.google.com/103462806772634246699... - EU

RE: Catia Macro to automatically measure spline

(OP)
@itsmyjob, powa copy saved my life :))

Sooooo, after some half a day fiddling with "powa copy", I managed to get the job done let's say 90%.

For the remaining 10% i need the help of you guys.

You can find attached the original power copy file with all the stuff needed.To make it work you just need a spline and a point.

The hard part is still self referral.
I am trying to fill in the Product Description field with "lungime_aproximata" parameter.
This works perfect in the original (model_conductor) part, but when I try to instance the power copy, everything is ok, except for formula 13.This is happening because "model_conductor" is still in the formula, a thing which now doesn't exist.

How do I get over this, so the formula retrieves the correct part name (the current part name), like this:

Formula.13:'part_xxx\Product Description'=lungime_aproximata

and not like this

Formula.13:'model_conductor\Product Description'=lungime_aproximata

Any help appreciated.







Best regards,
Costin Ruja

RE: Catia Macro to automatically measure spline

like i said I would use reaction to update the description... do you have KWE / A license?

Eric N.
indocti discant et ament meminisse periti

RE: Catia Macro to automatically measure spline

(OP)
Yes ! I do have it, it's knowledge advisor.And I already found the reaction button.Right now i'm looking for some details on how to use this.

Thanks !

Best regards,
Costin Ruja

RE: Catia Macro to automatically measure spline

Wait so you've got Knowledge Advisor, yet your employer is too cheap to buy the Electrical Harness licenses? I think this thread sums up perfectly the old Deming saying of: "We are being ruined by best efforts of people who are doing the wrong thing." You clearly are doing a lot of work trying to come up with a solution for your problems here, but the right solution would be to just buy the Electrical Harness licenses. And the further you delve into Macro's and Reactions and Parameters, the harder it will be to ever make that call.

RE: Catia Macro to automatically measure spline

(OP)
@Belgiancadengineer

This is quite ok for us, let's say this stimulates our imagination. The very shitty part is that our company belongs to a group that uses Solidedge for their design work in a few weeks we will have to comply to their workflow. Think about using Catia for about 8 years and then going to Solidedge...

Best regards,
Costin Ruja

RE: Catia Macro to automatically measure spline

It's that kinda stuff that keeps work work and not joy. Deming would be spinning in his grave!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources