Use feature pointer instead of hardcoding feature names for your generic features

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Use feature pointer instead of hardcoding feature names for your generic features

    I found myself needing to create generic circles for rounded slots that are toleranced with TP in two directions (non-cylindrical). I had a lot of them and I haven't coded a script that would do this in a more automated way yet.

    Anyway, I was thinking about an easy way to do this, without having to hardcode the source feature name in every THEO and MEAS field and found this to be an easy and smart solution, well worth
    a share.


    Normally, you grab the THEO's and the MEAS from the source feature by hardcoding it in the generic feature:

    Code:
    Source feature = CIR1
    
    VÄ_SPÅRBREDD=ALLMÄN/CIRKEL,BEROENDE,REKTANGULÄRA,INRE,$
                NOM/XYZ,<CIR1.TX,CIR1.TY,CIR1.TZ>,$
                MÄTT/XYZ,<CIR1.X,CIR1.Y,CIR1.Z>,$
                NOM/IJK,<CIR1.TI,CIR1.TJ,CIR1.TK>,$
                MÄTT/IJK,<CIR1.I,CIR1.J,CIR1.K>,$
                DIAMETER/CIR1.TDIAM,CIR1.DIAM
    This is fine if you have to create one (1) generic feature.

    If you need to create several generic features, here's a nice way to solve it rather quickly and with less effort than going the route above:

    First, create a generic feature and change the THEO's and MEAS to reference a name that isn't used in your part program.
    In the example, I chose to reference a feature called "SLOTFEAT". This feature does not exist (yet) which is why all the SLOTFEAT
    references will turn red.

    Code:
    VÄ_SPÅRBREDD=ALLMÄN/CIRKEL,BEROENDE,REKTANGULÄRA,INRE,$
                NOM/XYZ,<SLOTFEAT.TX,SLOTFEAT.TY,SLOTFEAT.TZ>,$
                MÄTT/XYZ,<SLOTFEAT.X,SLOTFEAT.Y,SLOTFEAT.Z>,$
                NOM/IJK,<SLOTFEAT.TI,SLOTFEAT.TJ,SLOTFEAT.TK>,$
                MÄTT/IJK,<SLOTFEAT.I,SLOTFEAT.J,SLOTFEAT.K>,$
                DIAMETER/SLOTFEAT.TDIAM,SLOTFEAT.DIAM
    Now, assign a feature name to the SLOTFEAT variable that you want to reference (use) the values from:

    Code:
    TILLDELA/SLOTFEAT={VÄSPÅR}
    Here, the SLOTFEAT gets assigned to the feature named VÄSPÅR (rounded slot) in the program. Notice all the reds are gone now.
    So I have created a generic circle using the values from VÄSPÅR and the THEO and MEAS diameter from it (TDIAM, DIAM).
    I need to create another generic circle to hold the length from the rounded slot. Just copy the code used for the DIAM and
    change TDIAM and DIAM to TLENGTH and LENGTH (and choose another name for the generic feature):

    Code:
    VÄ_SPÅRLÄNGD=ALLMÄN/CIRKEL,BEROENDE,REKTANGULÄRA,INRE,$
                NOM/XYZ,<SLOTFEAT.TX,SLOTFEAT.TY,SLOTFEAT.TZ>,$
                MÄTT/XYZ,<SLOTFEAT.X,SLOTFEAT.Y,SLOTFEAT.Z>,$
                NOM/IJK,<SLOTFEAT.TI,SLOTFEAT.TJ,SLOTFEAT.TK>,$
                MÄTT/IJK,<SLOTFEAT.I,SLOTFEAT.J,SLOTFEAT.K>,$
                DIAMETER/SLOTFEAT.TLENGTH,SLOTFEAT.LENGTH
    I need several of those, so I copy the first two generics and paste them, I need two generics per rounded slot.
    Make sure to rename the features after pasting. It looks something like this:

    Code:
    TILLDELA/SLOTFEAT={VÄSPÅR}
    
    VÄ_SPÅRBREDD=ALLMÄN/CIRKEL,BEROENDE,REKTANGULÄRA,INRE,$
                NOM/XYZ,<SLOTFEAT.TX,SLOTFEAT.TY,SLOTFEAT.TZ>,$
                MÄTT/XYZ,<SLOTFEAT.X,SLOTFEAT.Y,SLOTFEAT.Z>,$
                NOM/IJK,<SLOTFEAT.TI,SLOTFEAT.TJ,SLOTFEAT.TK>,$
                MÄTT/IJK,<SLOTFEAT.I,SLOTFEAT.J,SLOTFEAT.K>,$
                DIAMETER/SLOTFEAT.TDIAM,SLOTFEAT.DIAM
    
    VÄ_SPÅRLÄNGD=ALLMÄN/CIRKEL,BEROENDE,REKTANGULÄRA,INRE,$
                NOM/XYZ,<SLOTFEAT.TX,SLOTFEAT.TY,SLOTFEAT.TZ>,$
                MÄTT/XYZ,<SLOTFEAT.X,SLOTFEAT.Y,SLOTFEAT.Z>,$
                NOM/IJK,<SLOTFEAT.TI,SLOTFEAT.TJ,SLOTFEAT.TK>,$
                MÄTT/IJK,<SLOTFEAT.I,SLOTFEAT.J,SLOTFEAT.K>,$
                DIAMETER/SLOTFEAT.TLENGTH,SLOTFEAT.LENGTH
    
    MI_SPÅRBREDD=ALLMÄN/CIRKEL,BEROENDE,REKTANGULÄRA,INRE,$
                NOM/XYZ,<SLOTFEAT.TX,SLOTFEAT.TY,SLOTFEAT.TZ>,$
                MÄTT/XYZ,<SLOTFEAT.X,SLOTFEAT.Y,SLOTFEAT.Z>,$
                NOM/IJK,<SLOTFEAT.TI,SLOTFEAT.TJ,SLOTFEAT.TK>,$
                MÄTT/IJK,<SLOTFEAT.I,SLOTFEAT.J,SLOTFEAT.K>,$
                DIAMETER/SLOTFEAT.TDIAM,SLOTFEAT.DIAM
    
    MI_SPÅRLÄNGD=ALLMÄN/CIRKEL,BEROENDE,REKTANGULÄRA,INRE,$
                NOM/XYZ,<SLOTFEAT.TX,SLOTFEAT.TY,SLOTFEAT.TZ>,$
                MÄTT/XYZ,<SLOTFEAT.X,SLOTFEAT.Y,SLOTFEAT.Z>,$
                NOM/IJK,<SLOTFEAT.TI,SLOTFEAT.TJ,SLOTFEAT.TK>,$
                MÄTT/IJK,<SLOTFEAT.I,SLOTFEAT.J,SLOTFEAT.K>,$
                DIAMETER/SLOTFEAT.TLENGTH,SLOTFEAT.LENGTH
    
    HÖHI_SPÅRBREDD=ALLMÄN/CIRKEL,BEROENDE,REKTANGULÄRA,INRE,$
                NOM/XYZ,<SLOTFEAT.TX,SLOTFEAT.TY,SLOTFEAT.TZ>,$
                MÄTT/XYZ,<SLOTFEAT.X,SLOTFEAT.Y,SLOTFEAT.Z>,$
                NOM/IJK,<SLOTFEAT.TI,SLOTFEAT.TJ,SLOTFEAT.TK>,$
                MÄTT/IJK,<SLOTFEAT.I,SLOTFEAT.J,SLOTFEAT.K>,$
                DIAMETER/SLOTFEAT.TDIAM,SLOTFEAT.DIAM
    
    HÖHI_SPÅRLÄNGD=ALLMÄN/CIRKEL,BEROENDE,REKTANGULÄRA,INRE,$
                NOM/XYZ,<SLOTFEAT.TX,SLOTFEAT.TY,SLOTFEAT.TZ>,$
                MÄTT/XYZ,<SLOTFEAT.X,SLOTFEAT.Y,SLOTFEAT.Z>,$
                NOM/IJK,<SLOTFEAT.TI,SLOTFEAT.TJ,SLOTFEAT.TK>,$
                MÄTT/IJK,<SLOTFEAT.I,SLOTFEAT.J,SLOTFEAT.K>,$
                DIAMETER/SLOTFEAT.TLENGTH,SLOTFEAT.LENGTH
    
    BOHÖ_SPÅRBREDD=ALLMÄN/CIRKEL,BEROENDE,REKTANGULÄRA,INRE,$
                NOM/XYZ,<SLOTFEAT.TX,SLOTFEAT.TY,SLOTFEAT.TZ>,$
                MÄTT/XYZ,<SLOTFEAT.X,SLOTFEAT.Y,SLOTFEAT.Z>,$
                NOM/IJK,<SLOTFEAT.TI,SLOTFEAT.TJ,SLOTFEAT.TK>,$
                MÄTT/IJK,<SLOTFEAT.I,SLOTFEAT.J,SLOTFEAT.K>,$
                DIAMETER/SLOTFEAT.TDIAM,SLOTFEAT.DIAM
    
    BOHÖ_SPÅRLÄNGD=ALLMÄN/CIRKEL,BEROENDE,REKTANGULÄRA,INRE,$
                NOM/XYZ,<SLOTFEAT.TX,SLOTFEAT.TY,SLOTFEAT.TZ>,$
                MÄTT/XYZ,<SLOTFEAT.X,SLOTFEAT.Y,SLOTFEAT.Z>,$
                NOM/IJK,<SLOTFEAT.TI,SLOTFEAT.TJ,SLOTFEAT.TK>,$
                MÄTT/IJK,<SLOTFEAT.I,SLOTFEAT.J,SLOTFEAT.K>,$
                DIAMETER/SLOTFEAT.TLENGTH,SLOTFEAT.LENGTH
    The problem now is that all of these generics reference the same source feature - VÄSPÅR. We need to have separate source features for our generics.
    Here's the nice part, we only need to insert the assignment for SLOTFEAT for each of the pair:

    Code:
    [B]TILLDELA/SLOTFEAT={VÄSPÅR}[/B]
    
    VÄ_SPÅRBREDD=ALLMÄN/CIRKEL,BEROENDE,REKTANGULÄRA,INRE,$
                NOM/XYZ,<SLOTFEAT.TX,SLOTFEAT.TY,SLOTFEAT.TZ>,$
                MÄTT/XYZ,<SLOTFEAT.X,SLOTFEAT.Y,SLOTFEAT.Z>,$
                NOM/IJK,<SLOTFEAT.TI,SLOTFEAT.TJ,SLOTFEAT.TK>,$
                MÄTT/IJK,<SLOTFEAT.I,SLOTFEAT.J,SLOTFEAT.K>,$
                DIAMETER/SLOTFEAT.TDIAM,SLOTFEAT.DIAM
    
    VÄ_SPÅRLÄNGD=ALLMÄN/CIRKEL,BEROENDE,REKTANGULÄRA,INRE,$
                NOM/XYZ,<SLOTFEAT.TX,SLOTFEAT.TY,SLOTFEAT.TZ>,$
                MÄTT/XYZ,<SLOTFEAT.X,SLOTFEAT.Y,SLOTFEAT.Z>,$
                NOM/IJK,<SLOTFEAT.TI,SLOTFEAT.TJ,SLOTFEAT.TK>,$
                MÄTT/IJK,<SLOTFEAT.I,SLOTFEAT.J,SLOTFEAT.K>,$
                DIAMETER/SLOTFEAT.TLENGTH,SLOTFEAT.LENGTH
    
    [B]TILLDELA/SLOTFEAT={MISPÅR}[/B]
    
    MI_SPÅRBREDD=ALLMÄN/CIRKEL,BEROENDE,REKTANGULÄRA,INRE,$
                NOM/XYZ,<SLOTFEAT.TX,SLOTFEAT.TY,SLOTFEAT.TZ>,$
                MÄTT/XYZ,<SLOTFEAT.X,SLOTFEAT.Y,SLOTFEAT.Z>,$
                NOM/IJK,<SLOTFEAT.TI,SLOTFEAT.TJ,SLOTFEAT.TK>,$
                MÄTT/IJK,<SLOTFEAT.I,SLOTFEAT.J,SLOTFEAT.K>,$
                DIAMETER/SLOTFEAT.TDIAM,SLOTFEAT.DIAM
    
    MI_SPÅRLÄNGD=ALLMÄN/CIRKEL,BEROENDE,REKTANGULÄRA,INRE,$
                NOM/XYZ,<SLOTFEAT.TX,SLOTFEAT.TY,SLOTFEAT.TZ>,$
                MÄTT/XYZ,<SLOTFEAT.X,SLOTFEAT.Y,SLOTFEAT.Z>,$
                NOM/IJK,<SLOTFEAT.TI,SLOTFEAT.TJ,SLOTFEAT.TK>,$
                MÄTT/IJK,<SLOTFEAT.I,SLOTFEAT.J,SLOTFEAT.K>,$
                DIAMETER/SLOTFEAT.TLENGTH,SLOTFEAT.LENGTH
    
    [B]TILLDELA/SLOTFEAT={HÖHISPÅR}[/B]
    
    HÖHI_SPÅRBREDD=ALLMÄN/CIRKEL,BEROENDE,REKTANGULÄRA,INRE,$
                NOM/XYZ,<SLOTFEAT.TX,SLOTFEAT.TY,SLOTFEAT.TZ>,$
                MÄTT/XYZ,<SLOTFEAT.X,SLOTFEAT.Y,SLOTFEAT.Z>,$
                NOM/IJK,<SLOTFEAT.TI,SLOTFEAT.TJ,SLOTFEAT.TK>,$
                MÄTT/IJK,<SLOTFEAT.I,SLOTFEAT.J,SLOTFEAT.K>,$
                DIAMETER/SLOTFEAT.TDIAM,SLOTFEAT.DIAM
    
    HÖHI_SPÅRLÄNGD=ALLMÄN/CIRKEL,BEROENDE,REKTANGULÄRA,INRE,$
                NOM/XYZ,<SLOTFEAT.TX,SLOTFEAT.TY,SLOTFEAT.TZ>,$
                MÄTT/XYZ,<SLOTFEAT.X,SLOTFEAT.Y,SLOTFEAT.Z>,$
                NOM/IJK,<SLOTFEAT.TI,SLOTFEAT.TJ,SLOTFEAT.TK>,$
                MÄTT/IJK,<SLOTFEAT.I,SLOTFEAT.J,SLOTFEAT.K>,$
                DIAMETER/SLOTFEAT.TLENGTH,SLOTFEAT.LENGTH
    
    [B]TILLDELA/SLOTFEAT={BOHÖSPÅR}[/B]
    
    BOHÖ_SPÅRBREDD=ALLMÄN/CIRKEL,BEROENDE,REKTANGULÄRA,INRE,$
                NOM/XYZ,<SLOTFEAT.TX,SLOTFEAT.TY,SLOTFEAT.TZ>,$
                MÄTT/XYZ,<SLOTFEAT.X,SLOTFEAT.Y,SLOTFEAT.Z>,$
                NOM/IJK,<SLOTFEAT.TI,SLOTFEAT.TJ,SLOTFEAT.TK>,$
                MÄTT/IJK,<SLOTFEAT.I,SLOTFEAT.J,SLOTFEAT.K>,$
                DIAMETER/SLOTFEAT.TDIAM,SLOTFEAT.DIAM
    
    BOHÖ_SPÅRLÄNGD=ALLMÄN/CIRKEL,BEROENDE,REKTANGULÄRA,INRE,$
                NOM/XYZ,<SLOTFEAT.TX,SLOTFEAT.TY,SLOTFEAT.TZ>,$
                MÄTT/XYZ,<SLOTFEAT.X,SLOTFEAT.Y,SLOTFEAT.Z>,$
                NOM/IJK,<SLOTFEAT.TI,SLOTFEAT.TJ,SLOTFEAT.TK>,$
                MÄTT/IJK,<SLOTFEAT.I,SLOTFEAT.J,SLOTFEAT.K>,$
                DIAMETER/SLOTFEAT.TLENGTH,SLOTFEAT.LENGTH
    Done!

    - Create a generic feature referencing a non-existent feature of yours.
    - Assign a {featurename} to your non-existent feature
    - Copy the generic feature to as many as you need
    - Insert a new assignment referencing other source features

    Enjoy!
    PC-DMIS CAD++ 2o19 R1 SP11

  • #2
    Alternatively, you could modify the ToPoints.BAS script to generate generic features from a selected feature. Most of the code is already there…

    Or use the GENERIC.BAS I presented in https://www.pcdmisforum.com/forum/pc...287#post433287
    Last edited by AndersI; 09-06-2019, 08:18 AM.
    AndersI
    SW support - Hexagon Metrology Nordic AB

    Comment


    • vpt.se
      vpt.se commented
      Editing a comment
      Several ways to skin a cat

Related Topics

Collapse

Working...
X