0

Trying to draw a circular board shape in Altium Professional. enter image description here I am getting this error message for all methods in this script, including BoardOutline, RemoveAllVertices and AddVertex. Why is Altium asking me to declare these "identifiers" when they are supposedly built in methods?

I asked chatgpt how to draw the circle, and followed each instruction.

Chatgpt:

To make the board circular in Altium Designer using Pascal scripting, you can modify the BoardOutline property of the IPCB_Board interface. Here's an example code snippet to create a circular board shape:

pascal

Copy code
var
  PCBBoard: IPCB_Board;
  BoardShape: IPCB_BoardShape;
  Vertices: T2DVertexes;
  CenterX, CenterY, Radius: Double;
  Angle: Double;
  NumSegments: Integer;
  i: Integer;
begin
  // Get the current PCB board
  PCBBoard := PCBServer.GetCurrentPCBBoard;

  // Access the board shape
  BoardShape := PCBBoard.BoardOutline;

  // Clear existing vertices
  BoardShape.RemoveAllVertices;

  // Define the center coordinates and radius of the circle
  CenterX := MilsToCoord(5000); // Center X coordinate in mils
  CenterY := MilsToCoord(5000); // Center Y coordinate in mils
  Radius := MilsToCoord(5000); // Radius in mils

  // Define the number of segments to approximate the circle
  NumSegments := 100;

  // Calculate and add vertices to approximate the circular shape
  for i := 0 to NumSegments - 1 do
  begin
    Angle := i * 2 * Pi / NumSegments;
    Vertices.AddVertex(CenterX + Radius * Cos(Angle), CenterY + Radius * Sin(Angle));
  end;

  // Update the board shape
  BoardShape.UpdateVertices;
end;

In the code snippet above, we retrieve the current PCB board using PCBServer.GetCurrentPCBBoard. Then, we access the BoardOutline property of the IPCB_Board interface to get the board shape object.

We clear any existing vertices from the BoardShape object using the RemoveAllVertices method. Next, we define the center coordinates (CenterX and CenterY) and the radius of the circle (Radius) in mils.

We also specify the number of segments (NumSegments) to approximate the circular shape. In this example, we use 100 segments.

We then calculate the angle for each segment and add the corresponding vertices to approximate the circular shape using the Vertices.AddVertex method.

Finally, we update the board shape by calling the UpdateVertices method of the BoardShape object.

Remember to save your changes and update the PCB document for the circular board shape to take effect.

I hope this helps!

2
  • Have you checked official Altium documentation? DO mind that ChatGPT is not basing its answer on current information but on limited data that includes information till year 2021. This means that in your case ChatGPT answer might have been generated on possibly obsolete API documentation. Jun 10 at 9:06
  • 2
    The text "enter image description here" is not for fun. Likewise don't post pictures if it could be done in text, f.e. just pasting the error message and commenting in your code where it occurs.
    – AmigoJack
    Jun 10 at 18:32

1 Answer 1

0

Altium board outline is an polygon defined by polysegments. PolyRegion.ViewableObjectID = eViewableObject_BoardOutline;

And Polygons have property/methods: .PointCount // integer .Segments(i); // TPolySegment

PolySegment is either ePolySegmentLine or Arc & defined in similar way as IPCB_Track & IPCB_Arc.

The Altium provided script examples includes a board outline export/import script (IIRC).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.