Jump to content

Welcome to eMastercam

Register now to participate in the forums, access the download area, buy Mastercam training materials, post processors and more. This message will be removed once you have signed in.

Use your display name or email address to sign in:

Zaffin_D

Verified Members
  • Posts

    374
  • Joined

  • Days Won

    1

Posts posted by Zaffin_D

  1. On 5/13/2021 at 2:39 PM, crazy^millman said:

    Are you trying to come up with the angle between each of them rolled?

    IMHO best way is to unroll the diameter of the arc to create the circumference. Then from there you can do the math to solve the angle for each feature.

    Another way to do it is put a point in each arc and roll those points with Zero Diameter from where you are. I converted the splines for the holes to arc. I rolled it using .0001 diameter. I then used Transform rotate in 2D using the front plane at the C Plane. I aligned the axis to the point using change relative position in transform. I then put in back in rotate and moved the original arc 4 times to each of the indexing using this method. Now i have 4 arcs spaced like you had and then extruded them both ways to create the solid with the holes in there.

    Here is the file with the new geometry on level 100.

    5th Axis Wrap Test

     

    Segment length / radius should give you the angle in radians.  The file you uploaded has 40.365 degrees between the close holes; my math lands at 39.4261degrees.

    1.18699992 / 1.725 = 0.6881158956521739 radians or 39.4261366 degrees.  I used the roll function to confirm, what am I missing?

    image.png.ab82749d9358a3515cfc9b200d31db85.png

     

  2. 16 minutes ago, Compaq007 said:

    Thanks for the example code,🙏 it would have taken me a gazillion hours to figure  the Matrix part of it. :rtfm:

    That was provided just to show the math; you don't actually need it.  The below method leverages the provided math stuff and achieves the same result.

            public Point3D ConvertToViewCoordinates(Point3D point, MCView destinationView)
            {
                var destinationViewMappedOrigin = ViewManager.ConvertToViewCoordinates(destinationView.ViewOrigin, destinationView);
    
                return ViewManager.ConvertToViewCoordinates(point, destinationView) - destinationViewMappedOrigin;
            }

     

    • Like 2
  3. ViewManager.ConvertToViewCoordinates only appears to map the point; it doesn't seem to include the origin.

     Below is a short example showing how to take the shift into account.

    using Mastercam.App;
    using Mastercam.App.Types;
    
    using Mastercam.IO;
    using Mastercam.IO.Types;
    
    using Mastercam.Math;
    using Mastercam.Database;
    
    
    namespace pointMappingExample
    {
        public class Main : NetHook3App
        {
            public override MCamReturn Run(int param)
            {
                var selectedPoint = new Point3D(0, 0, 1);
    
                SelectionManager.AskForPoint("Select a point", PointMask.Null, ref selectedPoint);
    
                PromptManager.WriteString("Select the source view");
    
                var sourceView = ViewManager.SelectFromPlaneList();
    
                PromptManager.WriteString("Select the destination view");
    
                var destinationView = ViewManager.SelectFromPlaneList();
    
                PromptManager.Clear();
    
                var pointService = new PointService();
    
                var convertedPoint = pointService.ConvertToViewCoordinates(selectedPoint,
                                                                           destinationView);
    
                var transformedPoint = pointService.TransformToViewCoordinates(selectedPoint,
                                                                               sourceView,
                                                                               destinationView);
    
                DialogManager.OK($"Selected point(world)\n" +
                                 $"    X:{selectedPoint.x}\n" +
                                 $"    Y:{selectedPoint.y}\n" +
                                 $"    Z:{selectedPoint.z}" +
                                 $"\n" +
                                 $"Converted point({destinationView.ViewName})\n" +
                                 $"    X:{convertedPoint.x}\n" +
                                 $"    Y:{convertedPoint.y}\n" +
                                 $"    Z:{convertedPoint.z}" +
                                 $"\n" +
                                 $"Transformed point({destinationView.ViewName})\n" +
                                 $"    X:{transformedPoint.x}\n" +
                                 $"    Y:{transformedPoint.y}\n" +
                                 $"    Z:{transformedPoint.z}",
                                 $"Results");
    
                return MCamReturn.NoErrors;
            }
    
        }
        
    
        public class PointService
        {
            //Short method
            public Point3D ConvertToViewCoordinates(Point3D point, MCView destinationView)
            {
                var destinationViewMappedOrigin = destinationView.ViewMatrix.MapPoint(destinationView.ViewOrigin);
    
                return ViewManager.ConvertToViewCoordinates(point, destinationView) - destinationViewMappedOrigin;
            }
    
            //Long method
            public Point3D TransformToViewCoordinates(Point3D point, MCView sourceView, MCView destinationView)
            {
                var sourceViewMappedOrigin = sourceView.ViewMatrix.MapPoint(sourceView.ViewOrigin);
    
                var pointInSource = sourceView.ViewMatrix.MapPoint(point) - sourceViewMappedOrigin;
    
                var pointInTranspose = sourceView.ViewMatrix.GetTranspose().MapPoint(pointInSource) + sourceView.ViewOrigin;
    
                var destinationViewMappedOrigin = destinationView.ViewMatrix.MapPoint(destinationView.ViewOrigin);
    
                var pointInDestination = destinationView.ViewMatrix.MapPoint(pointInTranspose) - destinationViewMappedOrigin;
    
                return pointInDestination;
            }
        }
    
        public static class Matrix3DExtensions
        {
            public static Matrix3D GetTranspose(this Matrix3D m)
            {
                var rowOne = new Point3D(m.Row1.x,
                                         m.Row2.x,
                                         m.Row3.x);
    
                var rowtwo = new Point3D(m.Row1.y,
                                         m.Row2.y,
                                         m.Row3.y);
    
    
                var rowthree = new Point3D(m.Row1.z,
                                           m.Row2.z,
                                           m.Row3.z);
    
                return new Matrix3D(rowOne, 
                                    rowtwo, 
                                    rowthree);
            }
    
            public static Point3D MapPoint(this Matrix3D m, Point3D p)
            {
                var mappedX = (p.x * m.Row1.x) + (p.y * m.Row1.y) + (p.z * m.Row1.z);
                var mappedY = (p.x * m.Row2.x) + (p.y * m.Row2.y) + (p.z * m.Row2.z);
                var mappedZ = (p.x * m.Row3.x) + (p.y * m.Row3.y) + (p.z * m.Row3.z);
    
                return new Point3D(mappedX, mappedY, mappedZ);
            }
        }
    }

     

    • Like 1
  4. I think you’ll need to map the point yourself if it’s not in world coordinates to begin with.

    Try multiplying the point through the transpose/inverse (They are the same in a unitized, orthogonal DCM) of the source view’s DCM (matrix), then multiply that point through the destination matrix.

    With this method you can convert a point in any view to any other view; the source point doesn’t need to be in world coordinates. 

    Side note; you’re typing too much.  Add some using directives so you don’t need to type out the namespaces.

     

    • Like 1
  5. Just so you are aware, this is not an ideal use for opinfo.  When you tell opinfo to query an NCI line it searches the NCI file that’s on disc.

    I’m almost positive you can get the value you are looking from a traditional parameter in memory, have you done a parameter dump?

    Using opinfo on an NCI line should only be done if the data isn’t available in memory.

  6. On 3/27/2021 at 4:34 AM, Thee Byte™ said:

    The View Names Template is a good improvement.

    The User who suggested this improvement to me,

    also had an idea the ability to automatically rename the existing transformation Degree number in the name to the new tranformation #;

     

     

    For example,   

     

     

    Original Planes Name 1 -> "Custom User Plane a0." or "Custom User Plane X0."

    The user typed 45.

    Copied and transformed Planes Name 2 -> "Custom User Plane a45." or "Custom User Plane X45."

     

    The add-in should probably take the old rotation angle if there was one,

    and add the two angles together,  then change the x or a # to the result of the equation

    So if the user had a plane with the name x45 in it and the user entered another 45 degrees,

    the new planes name would be x90

     

    The Topic from Mastercam.com is here if you care to look.

    https://forum.mastercam.com/Topic16514.aspx

    That’s an interesting idea, but I’m not hot on it.

     Are you going to implement it?

      

  7. On 3/23/2021 at 9:24 PM, Thee Byte™ said:

    I see you added multiple instances as well, that's so useful.

    The U.I. looks amazing, I'm still stuck with 90's graphics with my winfotms. 😂

    Thanks!

    Multiple instances was the driving force behind this add-in, as everything else can be done in Mastercam OOTB.  I didn't like programing HMC's TOP-FRONT and wanted a quick way to create any number of views from an existing view and one of it's axes.

    I actually went a bit crazy the past few evenings reworking the UI to reduce clicks and adding a view name template so the resulting views' names can be customized.

    image.png.eb7382b6dda67d396acc2b39b6e70302.png

        

    • Like 1
  8. On 3/19/2021 at 5:57 PM, motor-vater said:

    singularity issue maybe???

     

    I'd expect the motion on the inside corners to be erratic.  Start at the lower right of the below image; notice how the flags (dark purple) are nicely flowing?  Once we hit the corner, big swings start to happen.

    image.thumb.png.d9c08fedc912947fef0fb70b07a385fd.png

     

    This could be avoided by fixturing the part at an angle, or by smoothing the instability across multiple moves.  The result of the latter is shown below.
    image.thumb.png.a8c7f22b68e1d4645bdec27adab1d864.png

     

  9. I'm not familiar with scandic characters, so I grabbed some random non-ascii ones for this example.

    s_return           : ""
    s_replacement_char : ""
    
    flktbl 1 4
        "A" "Ä"
        "E" "Ë"
        "I" "Ï"
        "O" "Ö"
    
    s_string           : "STRÏNG ÖF MÏXËD CHÄRÄCTERS"
    
    p_sanitize_s_string
        s_return = regex("([^\x00-\x7F])", s_string, 0)
        while strlen(s_return),
            [
            s_replacement_char = flook(1, s_return)
    
            s_string = regex(s_return, s_replacement_char, 2)
    
            s_return = regex("([^\x00-\x7F])", s_string, 0)
            ]
    
    psof$
        "BEFORE: ", s_string, e$
        p_sanitize_s_string
        *e$
        "AFTER:  ", s_string, e$

    Sample output

    BEFORE:  STRÏNG ÖF MÏXËD CHÄRÄCTERS
    
    AFTER:   STRING OF MIXED CHARACTERS

     

    You would have to add all the replacement characters to the look up table, and if the replacements are outside the ascii range the regex would need to be modified; but you get the idea.  

    • Like 1
  10. 1 hour ago, Thee Byte™ said:

    Perhaps using inline functions would help? Was this done in an managed or unmanaged environment? Or both?

    I've tried this both managed and native add-ins. The result is the same; MP takes time to spool up the process.  Also because of the serial nature of MP, nothing is happing until the called app returns.  It's not a big deal if you are doing it a handful of times, but it can get bothersome. 

    In this case (parsing a string) MP's regex function would be very useful and much quicker than sending it out to an external app. 

    Not to derail this, but I think you should look into what inline-ing does.

  11. 8 minutes ago, crazy^millman said:

    Yes that is going to be the issue because code expert is written to support $ as a defined variables in the MP language or end of line. Since you really need it to define a Spindle Variable going to be real tricky to get a Editor written to understand the dollar sign one way to do it a completely different way.

    Might look to Cimco Editor Pro it handles Streams. Beyond Compare is a different editor that allows you to write your own scripts and other things.

    Code expert’s highlighting is file dependent; nc files highlight differently than post files.

    The $ sign is not a problem, a proper regular expression needs to be used to identify the sync points.

    • Like 2
  12. 10 minutes ago, JParis said:

    If you can use G68.2 you can get helixes

    For that to be true the post would have to be configured to build the helical arcs from the linear data.  The NCI only contains linear moves with the axis control set to 4 or 5-axis.

  13. The ‘C’ in threadC means contour, so using it with a single entity is not really it’s intended use.

    Your reseller is correct, a custom post is required; I’m not aware of any CNC post that supports threadC.  This is because threadC writes it’s parameters to the NCI and doesn’t fill out the normal threading NCI lines.

    • Like 1
  14. 9 hours ago, keedo said:

    Thanks for the replys

    I have not altered anything yet😉

    Yes its a special character and its cumming from my tool library (tool comment)

    I just hoped that i could add a line of code, instead of going trough all my tool library's and manual deleting the ( ø )😃

     

    The thing is that in all my old tool library's  i have given all my tools names like " ø12 r2 " ø for the Diameter. 

    The old Haas machines that we have no problem. But the new Haas machine don't like this ø character and errors out. Evan though its only a comment inside ()

    If you are using Mastercam 2019 or later, use a regular expression to sanitize the string.

    s_regex       := "[^\x00-\x7F]"
    s_replacement := ""
    
    psof$
    	*e$
    	"Before: ", ~strtool$, e$
    	strtool$ = regex(s_regex, s_replacement, 2)
    	"After : ", ~strtool$, e$

    Sample output.

    Before:  Ø12 R0,2 *60 ISCAR
    After :  12 R0,2 *60 ISCAR

     

    • Like 3
  15. 1 hour ago, M.Bluedorn said:

    Hello all. This is my first posting but I've been gleaming knowledge from this forum for quite some time. So a belated thank you is due. What I'm trying to do is grab and store my POCO grab position which is param 13212, and then use that number in basically a comment at the beginning of the program. I've tried several different combinations of strategies I've learned from the MP Post Documentation and cannot get it to post anything other than the dreaded '-9999.' Any help would be greatly appreciated.

    Part handling operations don't have tool change lines.  The lack of a tool change means that opinfo doesn't 'see' part handling operations in it's offset(default) mode.  This means that you need to read the operation stream to look at all the operations.

    If you have questions about this I recommend you contact your reseller or post on CNC Software's forum.  

    • Like 1
  16. 8 hours ago, @Mastercam said:

    \bM([1-9][0-9][1-9]|[1-9][1-9][0-9]|[2-9][0-9][0-9])\b   { Current range is  101-999}

    Hi, 

    How i can increase the range to 1000-1099 

    Regex Programming Language- 

    1. Python 

    2.Java

    3. Javascript

    4.PHP

    5.c/c++ 

     

    Which Programming Language is used to Creating regex for Mastercam ?

    The following regex will match M1000 - M1099

    \bM10[0-9][0-9]\b

    Here is a link to it being checked against common M-codes  

    As far as what language is used; in this case it probably doesn't matter.  They all should support what you are trying to do.  One difference I'm aware of is the the C++ standard library regex implementation doesn't support lookbehind.  I think this goes for javascript also, but google will have a better answer if you care to get into the minutiae.

    • Like 1

Join us!

eMastercam - your online source for all things Mastercam.

Together, we are the strongest Mastercam community on the web with over 56,000 members, and our online store offers a wide selection of training materials for all applications and skill levels.

Follow us

×
×
  • Create New...