CATIA.StartCommand "Isolate" Stop Error Notifications

Michael Milez

CATIA.StartCommand "Isolate" Stop Error Notifications

Hello All,

I'm having difficulty finding a solution to the following problem. From the forums I have read so far it seems that there may be no solution based on the nature of the command.

Utilizing the following lines of code:

selection1.Search "type=geometric feature,all"
CATIA.StartCommand "Isolate"

I am getting error windows stating "This element cannot be isolated" for each element selected that can not be isolated. I understand that this is due to the selection containing geometric elements such as pads and pockets that may not be able to be isolated. I do not care about these items. If they exist I am fine with them not being isolated. I would like to just skip over these error windows. The "On Error Resume Next" does not seem to work because I'm guessing it is a Catia error and not a VBA error.

Is there a way to ignore these errors utilizing the CATIA.StartCommand, or is there a better way of isolating any/all features in the CATPart that are able to be isolated? Possibly cyling through each selected item using a For/Next, but the command would still be utilizing a CATIA.StartCommand unless there is another option that I am unaware of? Also, Copy Paste As Result will not work for this particular application either.

This process will be used on dozens or hundreds of parts within the assembly so I would like to keep the process automated. 

Any help would be greatly appreciated. Thank you!

Little Cthulhu

RE: CATIA.StartCommand "Isolate" Stop Error Notifications
(in response to Michael Milez)

I wonder what kind scenario you've got since you can't use "paste as result".

Anyway, it's possible create isolated features (called "datums") directly from code:

dim feat as AnyObject
set feat = CATIA.ActiveDocument.Selection.Item(1).Value

Dim prt as Part
set prt = CATIA.ActiveDocument.Part

Dim datums
datums = prt.HybridShapeFactory.AddNewDatums(prt.CreateReferenceFromObject(obj))

if TypeName(prt.InWorkObject) = "Body" then
prt.InWorkObject.InsertHybridShape datums(0)
else
prt.InWorkObject.AppendHybridShape datums(0)
end if

Josh Bender

RE: CATIA.StartCommand "Isolate" Stop Error Notifications
(in response to Michael Milez)

Michael,

What's your end goal? Are you doing extra design work after this point?  It seems unhelpful to remove everything from your model and turn it all into datum features.There may be some other options for you if you have a specific plan in mind. Can you elaborate on what you're trying to accomplish?

Michael Milez

RE: CATIA.StartCommand "Isolate" Stop Error Notifications
(in response to Josh Bender)

Little and Josh,

A brief description of the issue is for some unknown reason my company utilizes an "output" part to send to vendors to get details made. We don't send them the CATPart containing all of the design geometry. For some reason we publish out the solids and any other required features into separate CATPart's to release for manufacturing. To take this one step further, they require us (upon releasing for manufacturing) to copy the individual details to be manufactured into a separate folder (away from the main design folder) and isolate all of the items prior to releasing.

Why we do this? I wish I knew. It's incredibly frustrating and inefficient.

We also utilize a 3rd party software to attribute faces with machining values, not just a color (which is why paste as result will not work, those values will be lost and everything would need to be manually reattributed.)

Please understand that I think this workflow is just as stupid and I'm sure all of you are thinking it is, but I have no authority to modify the companies workflow processes so I need to work within their constraints.

So to answer the question of what my end goal is: I have created a macro that utilizes the Bill of Materials to identify output CATParts to be copied over based on property values into the correct folder, isolated, renamed, etc, automatically as opposed to current method of doing all that manually.

The code works brilliantly except for the aspect which I described earlier where if a designer for whatever reason places some type of geometric feature into the output part that can not be isolated (even though technically only published items should be contained in the output part) I end up getting error windows that need to be clicked on prior to continuing with the rest of the program. I don't care if these geometric features exists in the output part, so I would like to just skip over the warning when encountered.

Sorry, I know this was kind of a lengthy explanation about a poor workflow.

 

Little, I have not yet used the AddNewDatums code yet so I'm not exactly sure how that works, but I look forward to playing around with it to see if that will fit my application, or future applications for that matter. Thank you for that!

Josh Bender

RE: CATIA.StartCommand "Isolate" Stop Error Notifications
(in response to Michael Milez)

Wow. That does sound tedious. I guess it does make sense without a PLM system to manage revision levels. That way whatever is released can't be affected by someone making an accidental tweak or change to a file without intentionally updating every point along the process.

And to make thinks more complicated, you can't do a copy paste as result because it won't transfer the extra data already input directly into the file through the 3rd party utility?

I'm guessing that also means you can't use the Tools - Generate CATPart from product function either? Because the machining values won't be translated to the new part? So it's likely that using shape factory to create new, isolated items won't work either because the 3rd party software wont re-attribue the data to the new entity.

 

What is your normal process if you were to do this manually? Just right-click - Isolate each and every single feature of the part?

Michael Milez

RE: CATIA.StartCommand "Isolate" Stop Error Notifications
(in response to Josh Bender)

Exactly!  Lol. Unfortunately that’s exactly what we have to do at the moment. Hence why I am trying to write this macro. It will save an incredible amount of time extrapolated over each design. 

Josh Bender

RE: CATIA.StartCommand "Isolate" Stop Error Notifications
(in response to Michael Milez)

As your code stands now, does it work while in an assembly? ie does it actually go through each part and give you a million warning messages about what can't be isolated?

As to the 3rd party software - Do you know how it applies the attribute to an entity? Is it linked with BRep name? Maybe there is a way to trick it (or re-link it with a macro).

Maybe you could reduce the elements and update your search function to only select the types of elements that an Isolate could work on. I was looking through and I believe the only elements that can be isolated are lines, points, surfaces, and planes that are not already datum features.

This search function should return what you're looking for (except for Base R28 that has update/replace issues that were later fixed in a service pack)


CATIA.ActiveDocument.Selection.Search "('Generative Shape Design'.'Geometric feature'.IsDatum=FALSE - ('Part Design'.'PartDesign Feature'+'Part Design'.Plane.IsLeaf=TRUE)),all"


This avoids anything that is already a datum, a solid feature, or the origin planes. Only downside is that this takes FOREVER. It updates the part after each element is isolated, so if there are a lot of product features (or compounding steps) it turns forever. But I guess it's faster than you hunting and pecking.

Note: I didn't try this with any Boolean operations

 

Something to consider - you may be able to use this other search function to find every part design step:


CATIA.ActiveDocument.Selection.Search "'Part Design'.'PartDesign Feature'.IsLeaf=FALSE,all"


And then find the parent geometry of those objects and isolate that. Then you could run CATIA.StartCommand "Delete Useless Elements..." and clear everything else out. But that would need a bunch of different case conditions for each type of design element. Not really ideal.

Balla Zoltan

RE: CATIA.StartCommand "Isolate" Stop Error Notifications
(in response to Michael Milez)

Hi, have you already try to use CATIA.DisplayFileAlerts = False to avoid the Error messages?

 

Josh Bender

RE: CATIA.StartCommand "Isolate" Stop Error Notifications
(in response to Balla Zoltan)

I tried that with R28 with no luck.