TBC Macros and Extensions

 View Only
Expand all | Collapse all

How to Create Surface from Surface Tie

  • 1.  How to Create Surface from Surface Tie

    Posted 02-06-2023 16:44
    Hello Trimble Community,

    Will be grateful to know how to create a surface from surface tie? Let's say we have a Surface Tie as below:
     ST =wv.Add(clr.GetClrType(SurfaceTie))
                        ST.Name='mySurfaceTie'
                        ST.TieDirection=Side.Right
                        ST.CornerMethod=CornerRoundingMethod.Sharp
                        ST.CutSlope=float(self.cutSlope_TexBox.Text)
                        ST.FillSlope=float(self.fillSlope_TexBox.Text)
                        ST.StationDelta=float(self.StationingDelta_TextBox.Text)
    
                        ST.BegStation=float(self.startStation_TextBox.Text)
                        ST.EndStation=float(self.EndStation_TextBox.Text)
                        
                        ST.ReferenceGeometrySerial=l.SerialNumber
                        ST.SurfaceSerial=selectedSurface.SerialNumber​

    Then what will be the workflow to create a surface from this surface tie element? I checked the Model3D class constructor and it wasn't informative. (Trimble.Vce.Gem.Model3D)

    Another Question: What will be workflow if we start making surface from other features like points and lines to create a surface?

    Thanks,
    Morteza



    ------------------------------
    Morteza Kiani
    ------------------------------


  • 2.  RE: How to Create Surface from Surface Tie

    Posted 02-06-2023 19:04
    Haven't tested it but I would assume it works the same way as adding breaklines to a surface.

    addtosurface = []
    addtosurface.Add(ST)
    
    # this Model3D-method wants a list with the actual objects, not just the serial numbers
    selectedSurface.AddInfluences(addtosurface)​


    ------------------------------
    Ronny Schneider
    ------------------------------



  • 3.  RE: How to Create Surface from Surface Tie

    Posted 02-07-2023 11:00
    It throws an exception on me. Are you refereeing to "Trimble.Vce.Gem.Model3D.AddInfluences(System.Collections.IEnumerable)"  since I'm seeing two overloads here (below)
     
    Model3D Libarary
    I suppose the reason the "addtosurface" is defined as a list is to create an IEnumarable Collection  while it creates IronPython.Runtime.List (below screenshot). I understand that the List class is implementing the IEnumarable in .NET, However I'm not sure whether The IronPython.Runtime.List is comparable to System.Collection.IEnumarable?



    Is that the reason that it throws an error on me? Wrong Data Type or I'm missing something else?!

    ------------------------------
    Morteza Kiani
    ------------------------------



  • 4.  RE: How to Create Surface from Surface Tie

    Posted 02-07-2023 13:08
    I also redid that in C# to get the exception type since Python didn't give me enough info about the source of the exception:



    ------------------------------
    Morteza Kiani
    ------------------------------



  • 5.  RE: How to Create Surface from Surface Tie
    Best Answer

    Posted 02-07-2023 14:50
    I've tested it now and my code works fine in Python.

    For the rest I'm the wrong person to ask. I'm not a developer and have near to zero knowledge about C or C# and how they implement lists or variables.




    ------------------------------
    Ronny Schneider
    ------------------------------



  • 6.  RE: How to Create Surface from Surface Tie

    Posted 02-07-2023 15:17
    Thanks Ronny! I believe I skipped the Unique name and it was giving me the trouble. Is there anyway to recompute the project through the scripting?

    ------------------------------
    Morteza Kiani
    ------------------------------



  • 7.  RE: How to Create Surface from Surface Tie

    Posted 02-07-2023 19:20
    Is been shown in a few of the sample macros. With the following code the project is updated and you can Undo step by step.
    That's my improved version that will make sure that the end mark is set correctly. Otherwise the project explorer "crashes", is empty and you'd have to restart TBC.
    It also writes debug information (error type, line number) into a label that's at the end of each of my macro GUI's.

            self.currentProject.TransactionManager.AddBeginMark(CommandGranularity.Command, self.Caption)
            UIEvents.RaiseBeforeDataProcessing(self, UIEventArgs())
    
            try:
                with TransactMethodCall(self.currentProject.TransactionCollector) as failGuard:
    
    
                    failGuard.Commit()
                    UIEvents.RaiseAfterDataProcessing(self, UIEventArgs())
                    self.currentProject.TransactionManager.AddEndMark(CommandGranularity.Command)
    
    
            except Exception as e:
                tt = sys.exc_info()
                exc_type, exc_obj, exc_tb = sys.exc_info()
                # EndMark MUST be set no matter what
                # otherwise TBC won't work anymore and needs to be restarted
                self.currentProject.TransactionManager.AddEndMark(CommandGranularity.Command)
                UIEvents.RaiseAfterDataProcessing(self, UIEventArgs())
                self.error.Content += '\nan Error occurred - Result probably incomplete\n' + str(exc_type) + '\n' + str(exc_obj) + '\nLine ' + str(exc_tb.tb_lineno)
    ​



    ------------------------------
    Ronny Schneider
    ------------------------------



  • 8.  RE: How to Create Surface from Surface Tie

    Posted 02-07-2023 20:22
    Thank you very much for the quick response!

    Morteza

    ------------------------------
    Morteza Kiani
    ------------------------------