Skip to content

Instantly share code, notes, and snippets.

View benkoshy's full-sized avatar

Ben Koshy benkoshy

View GitHub Profile
@benkoshy
benkoshy / pagy-fix-group-date.md
Last active July 29, 2024 04:25
Pagy - fix group date

Updated

(2024-07-29 11:25 am GMT 7 Vietnam time):

bundle list

Gems included by the bundle:
  * actioncable (7.1.3.4)
  * actionmailbox (7.1.3.4)
@benkoshy
benkoshy / tekla-api-get-objects-currently-selected.md
Last active August 1, 2024 01:52
Tekla API: How to get objects that are currently selected.




In previous posts I have told you how to:

  • programatically select objects in Tekla. i.e. you have a set of parts in memory, and you want them selected.
@benkoshy
benkoshy / tekla-api-highlight-object.md
Created July 22, 2024 02:07
Tekla API - How to highlight model objects

We want to:

  • select an object,
  • and we need the user to understand that it has been selected.

This is done through: (i) highlighting it, and (ii) via a display prompt.

Don Norman elaborates on the need to alert users

@benkoshy
benkoshy / tekla-api-test-by-coordinate-systems-method.md
Last active July 11, 2024 08:05
Demonstrates how the ByCoordinateSystems method works using the Tekla Open API

Please review the MatrixFactory.ByCoordinateSystems Method in order to get the most out of this post. Particularly:

Returns a coordinate transformation matrix defined by two coordinate systems. With the returned matrix points can be transformed from the first coordinate system to the second coordinate system. The ByCoordinateSystems method is meant for transforming points between coordinate systems asked in the same work plane.

            //
@benkoshy
benkoshy / tekla-api-filter-parts.md
Last active July 8, 2024 05:20
How to programmatically filter parts by part position using the Tekla "Open" API

Here is the problem: we want to filter all parts which have the part position (or "part mark") of "p/2".

How can we do this programmatically?

Check out this code snippet - it assumes you have set up your references and are ready to go!

this.model = new Model();
if (model.GetConnectionStatus())
@benkoshy
benkoshy / plane-line-intersection-autocad-dot-net.md
Created March 12, 2024 03:45
Intersection of Line with a plane - AutoCAD .net Code

Source: https://paulbourke.net/geometry/pointlineplane/

  • We could use native AutoCAD methods to further simplify - this is just a 'hello world' proof of concept.
        [CommandMethod("TestCoordinates2")]
        public void TestCoordinates2()
        {
            Point3d p0 = new Point3d(0, 2, 0); // plane points
            Point3d p1 = new Point3d(0, 2, 1); // plane points
@benkoshy
benkoshy / idea_api.md
Last active January 31, 2024 02:12
Pagy jsonapi considerations

The Old Way

class QuotesController < ApplicationController  

  def index   
    # assuming jsonapi extra is enabled
    @pagy, @quotes = pagy(Quote.all) 

    # this will fail if we are using a html pagy_nav helper
@benkoshy
benkoshy / debug-tekla-plugin-without-restarting.md
Created December 6, 2023 23:29
How to Debug a Tekla Plugin Without Restarting Visual Studio (Tekla Open API Tutorial)

Post build plugin in visual studio.

Watch out - change the version ID to suit your Tekla version!

set envDir=2022.0\Environments\common\extensions\TestWPFBeamPlugin

set pluginsDir=2022.0\nt\bin\plugins\TestWPFBeamPlugin

set tsDirA=D:\Program Files\Tekla Structures\
@benkoshy
benkoshy / port_forwarding.md
Last active November 14, 2023 06:58
How to enable a port forwarding script - with iptables
#!/bin/bash

echo 1 > /proc/sys/net/ipv4/ip_forward # must be enabled for the forwarding to work

iptables -F 
iptables -t nat -F  # flush the nat table
iptables -t mangle -F
iptables -X