hexagon logo

Mark a range

Hello all,

I'm trying to write a script that will mark a range of dimensions for vector points.
I've tried a nested For each Cmd in Cmds inside a DO UNTIL LOOP, but my
"LOOP LOGIC IS LOUSY". Disappointed

I would like to enter the range from let's say feature PT150 to feature PT300
but only mark the the corresponding dimensions for the point features in that range.
The program would initially be unmarked, script would ask what the start feature name is
and the end feature name to complete the range and then mark the dimension in that
range only.

I'm sure the Code Guru's could whip the code out in no time without all the infinite loops
I generated. Slight smile

Thanks in advance for any help

  • Pseudocode:

    Establish the range to look for
    Parse all commands
    If current command is a dimension command then
    If sourcefeature or destinationfeature is in between the range then
    mark the command
    else
    Next command
  • VPT.SE.
    Thank you for the Pseudocode and the kick in the ass to attempt
    coding it my self Slight smile

    Not very elegant but this works with one little
    glitch.
    The end feature dimension is only partially marked.
    The xyz and t lines are not marked on only the last feature
    in the range. Everything other dimension in the range is completly marked.

    Is the Cmd.Redraw in the right spo?
    Hated to use a goto, but wanted to exit
    the FOR loop when last feature in the range was found.
    Thanks for your help.

    Dim SF As String
    Dim EF As String

    SF = InputBox("Enter the start feature :","StartFeature")
    EF = InputBox("Enter the end feature :","EndFeature")

    FoundStart = False

    For Each Cmd In Cmds
    If Cmd.IsDimension Then
    Set DimCmd = Cmd.DimensionCommand
    If DimCmd.feat1 = SF Then
    Cmd.Marked = TRUE
    FoundStart = TRUE
    End If
    IF DimCmd.feat1 <> EF AND FoundStart = TRUE Then
    Cmd.Marked = True
    End If
    IF DimCmd.feat1 = EF Then
    Cmd.Marked = True
    Cmd.Redraw
    GOTO Label_1
    End If
    End If
    Cmd.ReDraw
    Next Cmd
    Label_1:

    MsgBox "PROGRAM IS DONE"
    End Sub​
  • Good day,

    I don't know if you already have your solution, but this is how I would do it:

    Note:​
    * 'Cmd.Marked = True' marks the command for execution​ (The dimension commands are therefore executed and displayed in the report)
    * Only the dimension is displayed; the feartures are not changed
    * In my example the 'DimensionCommand' object is ignored and the command is looked at directly
    * The name of the feature entered must be exactly match

    Sub Main_230920()
    ' Dim something ---------------------------
      Dim App As Object
      Set App = CreateObject("PCDLRN.Application")
      Dim Part As Object
      Set Part = App.ActivePartProgram
      Dim Cmds As Object
      Set Cmds = Part.Commands
      Dim Cmd As Object
      Set Cmd = Nothing
     
      Dim sSF As String
      Dim sEF As String
      Dim bMarking As Boolean
      Dim bLast As Boolean
    
    ' get User input
      sSF = InputBox("Enter the start feature :", "StartFeature")
      sEF = InputBox("Enter the end feature :", "EndFeature")
     
    ' search
      bMarking = False
      bLast = False
      For Each Cmd In Cmds
        ' find first DIMENSION with input REF_ID "sSF"
        If (Cmd.Type = DIMENSION_START_LOCATION) And (Cmd.GetText(REF_ID, 0) = sSF) Then
          bMarking = True
        End If
        
        ' mark after find first
        If bMarking Then
          Cmd.Marked = True
        End If
        
        ' find last DIMENSION with input REF_ID "sEF"
        If (Cmd.Type = DIMENSION_START_LOCATION) And (Cmd.GetText(REF_ID, 0) = sEF) Then
          bLast = True
        End If
        
        ' exit after find last
        If (Cmd.Type = DIMENSION_END_LOCATION) And (bLast) Then
          Exit For
        End If
      Next Cmd
    
      Part.RefreshPart
    
    ' unDim something ---------------------------
      Set Cmd = Nothing
      Set Cmds = Nothing
      Set Part = Nothing
      Set App = Nothing
    End Sub​
    
  • Thanks Henniger123,
    There's more than one way to skin a cat. Your code is like precise incisions.
    Mine is like a butcher job. Both get the job done, with one a lot messier. Slight smile
    I'm learning a lot.
    Thanks again
  • Hello Henniger123,
    I tested your script today and the first feature has its dimension marked,
    but all the subsequent features and dimensions are marked until the last feature is
    is found and marked.
    I only want the dimensions marked not the features (vector points in this case).
    My version marks only the dimensions, but like I said previously the very last
    dimension is only partially marked. Haven't figured that out.
    I don't know why your version marks the first dimension, and then marks features
    and dimensions till the end.
    Probably just a small adjustment to the code?
  • yeah sorry, in my test I had the dimensions of all of them lined up one behind the other. so I didn't see my mistake
  • Hello,

    changed it


        ' mark after find first
        If bMarking Then     ' <- here is the mistake​
          Cmd.Marked = True
        End If​​
    
       ' should be:
        If ((bMarking) And (Cmd.IsDimension)) Or ((bMarking) And (Cmd.Type = DIMENSION_END_LOCATION)) Then
          Cmd.Marked = True
        End If​
    


    updated:
    Sub Main_230920()
    ' Dim something ---------------------------
      Dim App As Object
      Set App = CreateObject("PCDLRN.Application")
      Dim Part As Object
      Set Part = App.ActivePartProgram
      Dim Cmds As Object
      Set Cmds = Part.Commands
      Dim Cmd As Object
      Set Cmd = Nothing
     
      Dim sSF As String
      Dim sEF As String
      Dim bMarking As Boolean
      Dim bLast As Boolean
    
    ' get User input
      sSF = InputBox("Enter the start feature :", "StartFeature")
      sEF = InputBox("Enter the end feature :", "EndFeature")
     
    ' search
      bMarking = False
      bLast = False
      For Each Cmd In Cmds
        ' find first DIMENSION with input REF_ID "sSF"
        If (Cmd.Type = DIMENSION_START_LOCATION) And (Cmd.GetText(REF_ID, 0) = sSF) Then
          bMarking = True
        End If
        
        ' mark after find first
        If ((bMarking) And (Cmd.IsDimension)) Or ((bMarking) And (Cmd.Type = DIMENSION_END_LOCATION)) Then
          Cmd.Marked = True
        End If​    End If
        
        ' find last DIMENSION with input REF_ID "sEF"
        If (Cmd.Type = DIMENSION_START_LOCATION) And (Cmd.GetText(REF_ID, 0) = sEF) Then
          bLast = True
        End If
        
        ' exit after find last
        If (Cmd.Type = DIMENSION_END_LOCATION) And (bLast) Then
          Exit For
        End If
      Next Cmd
      Part.RefreshPart
    
    ' unDim something ---------------------------
      Set Cmd = Nothing
      Set Cmds = Nothing
      Set Part = Nothing
      Set App = Nothing
    End Sub​
    
  • That would be a Pcdmis setting. Generally it is set up so when you mark a dimension, it also marks the features required to produce that dimension. I think you need to change the Settings Editor entry for EWMarkDependMode from no entry (default is true) to FALSE so that it will not mark the dependent features for the dimension. There is also a EWMarkChildMode option which will mark the children of what you are marking. It has a default of FALSE (if nothing is selected). This is why (generally) you can mark a feature and the dimensions that are dependent on it do not get marked.

    Of course, this is the terminology used in the V3.7 settings editor. I wouldn't be surprised if they have changed it in newer versions.