// insert the usual references
Document doc = Application.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
using (Transaction tr = db.TransactionManager.StartTransaction())
{A method to create a rotated dimension using the AutoCAD .net API
protected void drawDimensions(Point3d dimensionPoint, Point3d point1, Point3d point2, double rotation)
{
using (Transaction tr = db.TransactionManager.StartTransaction())
{
BlockTable blockTable = tr.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable;
BlockTableRecord modelSpace = tr.GetObject(blockTable[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;// WARNING - it is REALLY REALLY hard to select a grid using this code.
// I no longer recommend this approach.
public PickGridLine(DrawingHandler drawingHandler, Model model)
{
if (drawingHandler.GetConnectionStatus())
{
this._picker = drawingHandler.GetPicker();- https://www.tek1.com.au/category/tekla-api/ For more API related content.
- Feel free to call Tek1 for all your shop drawing / API needs.
The Tekla API is not very open - one of my peeves is that you cannot access a drawing's revision number, because it is not exposed. Not to worry, you can access it with a hack:
using System;
using System.Collections.Generic;Sometimes you will want to query an object's properties - that you found in a drawing. How do you do that?
Let us suppose we have a single part. Then we need to:
- Get the Drawing
- Get the part identifier
- Select it in the model
SinglePartDrawing singlePartDrawing = (SinglePartDrawing)drawing;
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # https://benkoshy.github.io/2024/12/09/then-ruby-keyword.html | |
| # this is a contrived example | |
| # experiment with it in an IRB console. | |
| # we want to: | |
| # take a string | |
| # add convert it to an int | |
| # add 1 to that | |
| # and then cube it |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function onSubmit(e) { | |
| // some work is done here: | |
| // var form = FormApp.getActiveForm(); | |
| // var allResponses = form.getResponses(); | |
| // var latestResponse = allResponses[allResponses.length - 1]; | |
| // var response = latestResponse.getItemResponses(); | |
| // var payload = {}; | |
| // for (var i = 0; i < response.length; i++) { | |
| // var question = response[i].getItem().getTitle(); |
// We've all seen this line a thousand times before:
Document doc = Application.DocumentManager.CurrentDocument;
Database db = doc.Database;
// But what if we already have the database and we want to get the document?
// Then you could simply do this:
Document doc = Application.DocumentManager.GetDocument(db);Things which could be improved:
- Move away from API docs and Extras "docs" as separate pages ----> makes things harder to find and needlessly complicated.
- Improve "discoverability" problem. i.e. for example - to help readers answer the question: "which extras do I need, and why?" I feel I can improve upon this currently.
The rest:
- The rest of the docs seem pretty good. We have config options for advanced use cases.
Questions:
References:
- StackOverflow question
- Fibonacci Wikipedia
- Test it out in the go playground
package main
import "fmt"NewerOlder