Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

CATIA V5 script - creating mulitple holes on complex surface 3

Status
Not open for further replies.

longhduong

Aerospace
Jan 30, 2012
15
US
thread560-251808

Hi,
I am a beginner with scripts and was wondering.

If I have a complex (non planer) surface with multiple points defined within a geometric set, is there a way to instantiate multiple holes on that complex surface? Similar to user pattern but instead of choosing a sketch as the pattern you would choose the geo set of points.

I've read that this is possible but I have not seen any CATscript file on this.

Thanks for the help!

-Long
 
Replies continue below

Recommended for you

If you have the PKT license you don't need to script it, you can use a knowledge pattern.

 
I am not sure if I completely understand how to use knowledge pattern but it seems that you do need to write a script (ex. For Loop) within the knowledge pattern editor to create your pattern. My computer programming knowledge is very limited therefore I was asking if there was an existing script out there that would perform what I described.
 
I am still researching/experimenting with Knowledge Pattern but am a little stuck and could use some help.

I created a User Defined Feature (UDF), a HOLE that was created using 2 inputs, a FLAT surface and a point. Once saved into my catalog, I was able to instantiate more HOLE features using the catalog. However when I tried to instantiate the feature on a complex surfaces (non-planer), I was not able to select the complex surface as an input. In other words, I could only select FLAT surfaces.

I thought maybe it was the way I originally created the UDF so I tried to recreate the UDF using a HOLE feature that was created on a complex surface. However this proved unsuccessful as the UDF would not accept that feature.

I am still many steps away from creating a successful knowledge pattern but it seems as though this path may not work for my application especially since a UDF is required for the knowledge pattern and UDF is not possible in my case.

AM I MISSING SOMETHING? can anyone offer another alternative? possibly a script? thanks!
 
I think your problem with the udf is that is's made on a planar surface and therefor it's asking for a planar surface as input. Make the udf on a non-planar surface, it will work on planar... but other way around is not working.
 
Azrael,

I tried constructing the UDF from a HOLE element on a planer and non-planer surface but it does not accept the HOLE element from the non-planer surface. I keep getting the error message "ERROR IN DEFINITION"
 
Ok so at this point I've figured out how to make the feature using 2 separate UDF.

The first UDF (PlaneTangent) has 2 inputs (Surface, Point). The output is a PLANE tangent to that surface at the point

The second UDF (HoleNormal) has 2 inputs (Plane, Point). The output is a HOLE normal to the plane at the point.

Note, this works for both planer and non-planer surfaces. I also saved my UDF to catalog (ARMCatalog).

How would I write the code for the knowledge pattern to loop these UDF?
 
To simplify the process. I am trying to knowledge pattern 1 UDF at a time.

Here is what I have so far for the (PlaneTangent) UDF which creates a plane tangent to surface at point: (copied and manipulated from a different post from you - Catia V5 - Points to Spheres)


let i(integer)
let PointList(list)
let ListSize(integer)
let PlaneTangent(UserFeature)
PointList='Geometrical Set.1'.Query("Point","")
ListSize=SL->Size()

i=1
For i while i <=ListSize
{
PlaneTangent=CreateOrModifyTemplate("ARMCatalog|PlaneTangent",PlaneSet ,`Relations\KnowledgePattern.3\PlaneList` , i)
PlaneTangent->SetAttributeObject("Point",PlaneList ->GetItem(i))
EndModifyTemplate(PlaneTangent)
i=i+1
}



getting Syntax Error line 4:
Parameter' cannot be used in this context.

Given: I am using the same path/directory. Same catalog "ARMCatalog". My UDF is saved as "PlaneTangent.CATGScript". The Name is PlaneTangent. The Inputs are named "Point" and "Surface". The Type generation was Auto and is (SkinFeature) and the Type1 was titled PlaneTangent.

 
There are some issues I would like to adress here:)

You should be able to create just one udf. A good method creating a udf is to use an empty catpart and just add or create those elements that you want to use as input for the udf. In this case a curved surface and a point on the surface to start with, from that point create a line perpendicular to the surface and then a plane to place the hole/pocket.

I see that you "type" the udf to get the catgscript but have you also set the Knowledge environment in tools/option/parameters? So the KBE folder structure is created on the choosen path and the catgscript is created in the right place (knowldegeTypesCustom folder) and put the catalog and the part with udf in the knowledgeResourcesCatalogs folder. I've heard that this is not needed if the udf is in the same part as the pattern, that you can call on the udf directly, haven't tried it though... good to know maybe.

Regarding your code in the knowledge pattern I see some possible issues, it's little trickier when I don't see the environment and are not sure how you have made some steps.
You have typed the udf so I would try to declare it differently in the code, think that "let PlaneTangent(UserFeature)" can be used if it's not typed.
Try:
Let PTudf(PlaneTangent)
I'm just guessing that you have typed it as PlaneTangent, check the name of the catgscript.
You stated that the udf has two inputs but I only see one used in the code. A benefit with typed udf's are that you can directly call their inputs by their names.
Where is the other udf input? the surface? The variable SL is not declared, I guess it's the list

My version would look like:

let i(integer)
let PList(list)
let ListSize(integer)
let PTudf(PlaneTangent)

PList='Geometrical Set.1'.Query("Point","")
ListSize=PList->Size()

i=1
For i while i <=ListSize
PTudf=CreateOrModifyTemplate("ARMCatalog|PlaneTangent",PlaneSet ,`Relations\KnowledgePattern.3\PlaneList` , i)
PTudf.Point=(PList ->GetItem(i))
PTudf.Surface=??the missing surface???
EndModifyTemplate(PTudf)
i=i+1
}


Another interesting thing with knowledge patterns are that you can use it to create datum elements, with the function CreateOrModifyDatum, so this first udf you have made can be done in the code. Which R level du you have?
 
I am using R20, I now have the knowledge type path under options/paramters/knowledge to where I have my type saved, and I also have created the UDF from an new part and body.

To clarify why I think 2 UDF's are required; I am given a solid with complex surface and geometric set of points that represent center points for holes on that complex surface. The HOLE command in CATIA only requires 2 inputs to work(a point and surface). 1 UDF would work but for some reason I keep getting an error when trying to create this UDF. See attached 1.JPG for error message.

If the UDF required input was (point and plane) instead of (point and surface)then it works fine. However this means I would have to create an additional geometric set of planes to go with the points. This is why I thought it would be easier to create 2 UDF's. One UDF to create the planes tangent to the surface at the points and the second UDF to create the hole normal to those planes at the points.

That said If I can figure out how to get 1 UDF to work then I think I can eventually figure out how to get 2 to work. I've attached a few screenshots of my spec tree and knowledge pattern. Note this is just for 1 UDF, to create a plane tangent to the surface at the given point.

I don't know how to attach multiple attachments so I will have separate post for the other 3 attachments.

 
 http://files.engineering.com/getfile.aspx?folder=6481d333-552d-434c-b960-41e2f7268275&file=1.JPG
5.JPG
Change let PTudf(PlaneTangent)
let PTudf(Plane)



Win XP64
R20/21, 3DVIA Composer 2012, ST R20
Dell T7400 16GB Ram
Quadro FX 4800 - 1.5GB
 
1.jpg
This is open for debate, but selecting a face of a solid can lead to unstable models if you delete parent features. Personal preference for me would be to create a body and use a hole from a plane and point.



Win XP64
R20/21, 3DVIA Composer 2012, ST R20
Dell T7400 16GB Ram
Quadro FX 4800 - 1.5GB
 
 http://files.engineering.com/getfile.aspx?folder=a1ff7729-fd8f-417e-b25f-b2e4120143f7&file=hole_udf.JPG
I read on another forum that sometimes the code loses its link if it is copied and pasted into the editor. So I manually typed each line of code into the editor and that solved the syntax error on line 4 (see above 5.JPG).

I am now getting a Syntax error on line 12. See attached 6.JPG.
 
 http://files.engineering.com/getfile.aspx?folder=10868d38-fb20-4c20-b2c8-6fd9fe3a595e&file=6.JPG
What is PlaneSet? PlaneSet should be a geometric set. Does it exist? If so, delete the text and select it from the tree.

Win XP64
R20/21, 3DVIA Composer 2012, ST R20
Dell T7400 16GB Ram
Quadro FX 4800 - 1.5GB
 
I found my syntax mistake. I was using an apostrophe (') instead of the accent symbol (`). The knowledge pattern editor is now accepting the code. However when I execute the pattern I get the following 2 errors:

1) No resource with logical name PlaneTangent has been found in the catalog ARMCatalog (extended search not activated)
2)The string "ARMCatalog|PlaneTangent" given as identifier in the method CreateOrModifyTemplate is not correct:
either the catalog ARMCatalog does not exist or the catalog description PlaneTangent does not exist.

I verified, under tools/options/parameters and measure/knowledge environment, I've set the path for the "Reference Directory For Types" to (c:\...\knowledgeTypesCustom) and the "Architect Resources Creation Path" to (c:\...\knowledgeResourcesCatalogs). I've saved my catalog and UDF in the (c:\...\knowledgeResourcesCatalogs) folder.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Top