Disassemble surfaces in CATIA using VBA - vba

Is there a way to disassemble a surface in domains in CATIA through VBA, maintaining the dependencies between the initial surface and the separated domains?

I can suggest 2 options, I have already employed both of them in my works in a similar way. None of them will of course be guaranteed to update after input changes, but associativity with existing domains will exist.
Option 1:
Pick a random face in automation using Search (within topology option in the query string. To get to the right query string, first try it using manual searches with Include Topology option active).
Create two Extract with Point continuity based on this face: one will be the first domain you're looking for, the second will be in Complementary mode and the input for the next step
Repeat recursively from step 1 until all domains are extracted. Last complementary extract will probably raise an error (manage it with On Error Statement)
Option 2:
Disassemble in domains getting dumb surfaces, store them.
Create a point on surface on each of them
Create many Near, always on the same input surface, using each of the points obtained before.
If you don't like keeping relationships with dumb surfaces, insert this step after step 2: read point's coordinates using GetCoordinates method, then create another point by coordinates and use that into the Near. Then delete all dumb surfs and points created on them.
Regards

Related

SimpleElastix 3D rigid registration fails to find same image

I've been trying to get a basic registration working with SimpleElastix for a while now, but I'm not able to make it work at all, regardless of the settings used. Note that I'm trying to compare SimpleElastix to other methods, so using another library is not an option.
Here's the task I'm currently trying to do:
Take a 3D ultrasound scan of a fetus (img_scan)
Mask a part of the scan, and apply a rigid transform (img_structure)
Use SimpleElastix to register img_structure to img_scan.
Since img_structure was created from img_scan, I know for certain that there is an ideal solution to the registration. However, unless img_structure is extremely close to it's original position, SimpleElastix seems to barely do anything at all. For example, if I only translate img_structure in one axis, it works. But if I only rotate it 90 degrees, it fails although their centres are basically the same. To clarify, by fail I mean it returns a slightly transformed img_structure, but nowhere near the the actual solution]
This is the basic code I've started with:
elastixImageFilter = sitk.ElastixImageFilter()
elastixImageFilter.SetFixedImage(fixed)
elastixImageFilter.SetMovingImage(moving)
elastixImageFilter.SetMovingMask(mask_moving)
elastixImageFilter.SetFixedMask(mask_fixed)
elastixImageFilter.SetParameterMap(sitk.GetDefaultParameterMap("rigid"))
elastixImageFilter.Execute()
Things I have tried:
With/without masks (or a combination)
Different MaximumStepLength
Different ImageSampler
Affine instead of rigid
Different Optimizers
What could I be missing?

CATIA Script to Rename All Objects in Specification Tree

I am looking for a CATIA script to replace the names of all objects in the specification tree of a CATPart with a constant string suffixed by a running number. As an example, consider the following specification tree before renaming (left picture) and after the script run (right picture):
Background is the removal of sensitive information (such as part numbers of electronics components) for preparation of a STEP export of a large assembly.
Well this certainly is not a hard one to write and figure out. As I understand StackOwerflow is not a site where you get a code on demand but a site where you get help with your code.
I will give you a hint. What you are looking for are collections of objects which holds features, bodys, constrains etc. and iterate trough all these collections and change the names.
I would start recording macro when you manually change the names, then take a look at the script and learn from it.

Alter speed/feed by tool number

I need to use some new drills using unmodified original .MIN CNC programs for Okuma Thinc controller, MU6300V. I'm looking to use the Okuma API to detect when tool group 4 is loaded into the spindle and then alter the speed/feed when it drills. I am familiar with the API and .NET. Looking for some general guidance on objects/methods and approach.
If this is too difficult then I would settle for just modifying the feed rate when a G81 drill cycle is called for a tool in group 4.
The first part of your request is pretty straight-forward.
// Current Tool Number
Okuma.CMDATAPI.DataAPI.CTools.GetCurrentToolNumber();
// Group number of current tool
Okuma.CMDATAPI.DataAPI.CTools.GetGroupNo(CurrentToolNumber);
Altering the drill feed / speed will be more troublesome however.
You cannot set feed/speed overrides using the API.
That is, not without some additional hardware and special options.
Other people have done it actually.
Have you ever seen Caron Engineering's Tool Monitoring Adaptive Control?
Because I think that is essentially what you're asking for.
https://www.caroneng.com/products/tmac
The only other option you have is altering your part program to look for common variable values to set spindle speed and/or feed rate.
For Example
Use one variable to determine if fixed or variable value should be used, and another for the variable value
That way, on a machine that has your old drills and no THINC Application altering common variables, the fixed values are used. But, on a machine that has the application, it can look at the tool number or group and set a common variable that determines specific speed/feed values. Then those new values are used before starting the spindle and moving into the cut.
The choices available for changing feed/speed after the machine has entered a cut or commanded the spindle to run are:
Human operator at the control panel
TMAC

How to change node edge lines in Cytoscape.js?

I have a bunch of nodes on each side of a central node. I am trying to find a way to position the node lines so that they go to the right or left side of the nodes.
So for this:
http://jsbin.com/ipuxub/4/edit?js,output
I want the lines for the Jerry node to go to right side of Elaine, George, Kramer, etc.
While I don't think this is possible now:
Is there a way to force it, trick it or make it look better?
If it is changing the Cytoscape JS code, any suggestions to where I begin or look at or what would need to be changed?
Controlling edge control points more manually or adding support for node bend points are things we have planned to add in future, and I think either case would satisfy your use case.
However, we do not have the resources to do this in the short term: Both cases require our side to plan how those features would fit in with the model and visual style system (cy.js css).
In the short term, if you want to control where edges are drawn, you have to adjust the positions of the connected nodes -- because the edge positions are inferred between them. The first edge is straight between them, and for 2 or more beziers are used.
If moving node positions does not suffice for your usecase, the first steps would be for us to discuss and plan how this feature would work and how it would fit into the system: https://github.com/cytoscape/cytoscape.js/issues/359
Then if you're interested in implementing it, it would be a straightforward process. We could direct you to the relevant parts of the code that would need to be changed etc over a Google+ call.
Thanks -M

How to design this particular finite state machine?

I am trying to get my head around how to design the following system, which I think can be defined as a finite state machine:
Say we have a pile of 16 building blocks (towers, walls, gates) together forming a castle. The player can drag the blocks to 16 places on a floorplan and if done right they will see the whole castle. All towers (there's four of them) are equal so they can go on any of the four corners. Same goes for some of the walls.
All in all there are 16 spots on the floorplan where you can put a building block and each of the spots can have 17 "states": empty + either one of the 16 building blocks. Doing some maths this leads to 17^16=a LOT of combinations.
The program starts with an empty floorplan and a pile of building blocks. It should then show a message like "build your own castle, start with the tower". When the user places a tower correctly, it should say "well done, now build all four towers". You get the idea.
Problem is: there are so many things a player can do. Put a block at the wrong place, remove a block, correctly put walls or towers all over the floorplan ignoring the directions given to them, etc.
It would be awesome if I could avoid having to use thousands of if-then statements to decide wether I should take the next step, show an error message or go back to the previous step based on what the player is doing.
How would you describe the NEXT, PREVIOUS and ERROR conditions for every step of the building sequence? Are there any design methods for this? Thanks a lot for your input.
Try to do this declaratively. Define an enum (or possibly classes) describing the kinds of blocks. Define and construct a 4x4 2D array describing the sets of permissible kinds of blocks in each position (implement the sets as lists, bitfields, whatever suits you best). Whenever a player tries to place a block in a position, check whether it is permissible against the 2D array. If you want to have particular messages for a position being correctly filled in, also put those in the same an array.
I don't know if a FSM is really what you are after: what kinds of sequencing constraints are you looking to verify? Does it matter whether towers are built first? From the rest of your description, it sounds like the above goal state description would be more suitable.