Recent

Author Topic: LazCAD – First Release!  (Read 9472 times)

zamtmn

  • Hero Member
  • *****
  • Posts: 646
Re: LazCAD – First Release!
« Reply #45 on: November 15, 2024, 09:15:06 am »
I think that methods unique to entity type are not needed. There should be a universal "TransformBy" method for applying the transformation matrix, and universal methods for working with control points.
Different variants for working with specific entities are needed, but they are needed as separate procedures or gui commands, not as methods of entity class

maurog

  • New Member
  • *
  • Posts: 38
Re: LazCAD – First Release!
« Reply #46 on: November 15, 2024, 02:54:37 pm »
Thank you for your input and your perspective!
Your suggestion to use universal methods like TransformBy is already implemented internally. When the user works interactively, these transformations are applied in the background.

The SetCenterPoint method I’m currently implementing is specifically for the scripting interface that operates in batch mode. My goal is to make this interface as simple as possible so that end users can work with it without needing a deep understanding of transformations or computer graphics. To achieve this, I break down the functionality into small, easily understandable building blocks, offering the scripter an intuitive API.

The scripter/end user should not need to deal with the following complexity:
Code: Pascal  [Select][+][-]
  1. function Rotate2D(const R: TRealType): TTransf2D;
  2. begin
  3.   {
  4.     | cos(R)  sin(R)   0 |
  5.     | -sin(R) cos(R)   0 |
  6.     | 0       0        1 |
  7.   }
  8.   Result := IdentityTransf2D;
  9.   Result[1, 1] := cos(R);
  10.   Result[1, 2] := sin(R);
  11.   Result[2, 1] := -Result[1, 2];
  12.   Result[2, 2] := Result[1, 1];
  13. end;
  14.  
  15. function Scale2D(const Sx, Sy: TRealType): TTransf2D;
  16. begin
  17.   {
  18.     | Sx  0  0 |
  19.     | 0   Sy 0 |
  20.     | 0   0  1 |
  21.   }
  22.   Result := IdentityTransf2D;
  23.   Result[1, 1] := Sx;
  24.   Result[2, 2] := Sy;
  25. end;
  26.  
  27. procedure ScaleObject(AObject2D: TObject2D; AFactorX, AFactorY: TRealType);
  28. var TmpTransf2D: TTransf2D; TmpBottom: TRealType; TmpLeft: TRealType;
  29. begin
  30.   TmpBottom := AObject2D.Bottom;
  31.   TmpLeft := AObject2D.Left;
  32.   TmpTransf2D := Scale2D(AFactorX, AFactorY);
  33.   AObject2D.Transform(TmpTransf2D);
  34.   AObject2D.Bottom := TmpBottom;
  35.   AObject2D.Left   := TmpLeft;
  36. end;
  37.  

Instead, the end user should be able to work with the API simply, like this:
Code: Pascal  [Select][+][-]
  1. MyObject.Scale(2.0, 1.5);
  2. MyObject.Rotate(45);
  3. MyObject.MoveTo(100, 200);
  4. ...
  5. CircularArc2D.SetCenterPoint(x, y);
  6.  

I hope this helps clarify my approach a bit more. Again, thank you so much for your feedback!

PS: I apologize for not providing complete information in my initial request. I hope this additional context helps clarify my approach.
« Last Edit: November 15, 2024, 03:03:17 pm by maurog »
And yes, Lazarus is definitely a beast – it comes with everything you need, but sometimes also more than you expect. 😅 (Chat-GPT)

zamtmn

  • Hero Member
  • *****
  • Posts: 646
Re: LazCAD – First Release!
« Reply #47 on: November 16, 2024, 09:12:28 am »
I know 3 ways to create arc:
1 - CenterPoint,Radius,StartAngle,EndAngle
2 - StartPoint,OnArcPoint,EndPoint
3 - StartPoint,EndPoint,Bulge
I do not know why the script may need to move the center of the arc.
Besides, the first scenario you described is simple MyObject.MoveTo(..)

maurog

  • New Member
  • *
  • Posts: 38
Re: LazCAD – First Release!
« Reply #48 on: November 16, 2024, 02:33:30 pm »
@zamtmn

Thank you very much for your feedback and the helpful overview of the methods for creating an arc. I greatly appreciate your expertise and your work, especially since you have developed such an impressive CAD application yourself.

Perhaps I can explain the benefit of such functions from a scripting perspective in a bit more detail: The purpose of scripting is to give the user the ability to control all operations they can perform interactively via a script. This allows them to efficiently automate their work and significantly simplify repetitive tasks – similar to a shell script in Linux or a batch file in Windows.

Moreover, scripting not only offers automation but also extensibility. Users can use it to extend the main program with new workflows or even modules tailored to their specific needs. A typical example of this is creating a CAM post-processor.

Another important point is parametric drawing, which also frequently uses scripting in the background. Functions like MyObject.MoveTo(...) are crucial here, as they allow for dynamic adjustments and ensure that complex geometries can be precisely controlled through scripts.

Regarding your comment:
Quote
I do not know why the script may need to move the center of the arc.
The real purpose of scripting is to programmatically create, modify, and control objects. This allows the user to make precise changes and perform complex geometric operations efficiently.

I hope this clarifies the importance of such functions within the context of scripting. Thanks again for your thoughts on this and for the opportunity to share this perspective!
PS.
Quote
Besides, the first scenario you described is simple MyObject.MoveTo(..)
Yes, exactly, that was a mistake on my part. It’s already implemented, thank you! :-)
And yes, Lazarus is definitely a beast – it comes with everything you need, but sometimes also more than you expect. 😅 (Chat-GPT)

zamtmn

  • Hero Member
  • *****
  • Posts: 646
Re: LazCAD – First Release!
« Reply #49 on: November 17, 2024, 06:58:12 am »
I don't think it's possible to think about it in advance. Further use (writing) of scripts will show what is needed and what is not needed. For myself (in zcad), I realized that I don't need scripts yet. Perhaps later, to create reports in drawings

maurog

  • New Member
  • *
  • Posts: 38
Re: LazCAD – First Release!
« Reply #50 on: November 17, 2024, 11:32:35 am »
You’re absolutely right – it’s often only through practical use that it becomes clear which functions are truly needed. The idea of using scripts later for generating reports in drawings sounds promising and could definitely be useful in the future.
And yes, Lazarus is definitely a beast – it comes with everything you need, but sometimes also more than you expect. 😅 (Chat-GPT)

maurog

  • New Member
  • *
  • Posts: 38
Re: LazCAD – First Release!
« Reply #51 on: November 17, 2024, 12:48:16 pm »
Because we mentioned scripting, on the other hand, a clearly defined scripting interface or a simple plug-in mechanism for a large project like ZCAD, which is naturally associated with a certain level of complexity, could be a valuable way to attract new developers. Such an interface would allow the application to be broken down into smaller, more manageable parts, making it easier for developers to get started. They could then focus on specific extensions or customizations without needing to engage with the entire structure of the project. This could help open up the project further and expand the community.
And yes, Lazarus is definitely a beast – it comes with everything you need, but sometimes also more than you expect. 😅 (Chat-GPT)

zamtmn

  • Hero Member
  • *****
  • Posts: 646
Re: LazCAD – First Release!
« Reply #52 on: November 17, 2024, 06:28:58 pm »
  I am not a programmer and have no experience developing CAD programs. ZCAD is big and complex, but it is still an experiment. There is a lot of code when I try to do something in different ways, gradually settling on the best one.
  I added LAPE scripting language integration, got the ability to draw simple primitives on the drawing, and stopped there for now. I don't think it's necessary right now and doed just for a check mark - means to redo it later.
  I'm interested in interactivity, for example to have a script-generated report automatically change with changes in the drawing or smart primitives that are a cable or a device, not just a line or a square.
  Also the speed of the program with huge drawings is very important to me, I spend a lot of effort to improve it.
Bringing in developers is certainly interesting, but I won't be able to provide a fixed API right now, some fundamental stuff hasn't been finalized yet. Another thing is to attract users. Users don't need APIs and scripts, they need stability, speed and compatibility with autocad

maurog

  • New Member
  • *
  • Posts: 38
Re: LazCAD – First Release!
« Reply #53 on: November 17, 2024, 08:33:03 pm »
Thanks for the explanation! I understand and find it exciting to see how it will develop. Wishing you lots of success with your work on ZCAD.
And yes, Lazarus is definitely a beast – it comes with everything you need, but sometimes also more than you expect. 😅 (Chat-GPT)

maurog

  • New Member
  • *
  • Posts: 38
New LazCAD Version Available
« Reply #54 on: November 20, 2024, 06:05:01 pm »
Hello everyone,

I’ve uploaded a new version of LazCAD. Here are the main updates:

RuntimeScripter: The scripter is now integrated and fully functional.
Limitation:
The ScripterIDE currently does not support multi-line comments in the {...} format. When importing code from Delphi, issues may occur. However, single-line comments in the // format are supported without any issues.


Simple Help: A basic HTML help system with multiple pages has been added.
It’s not complete yet but includes an overview of the RuntimeScripter functions,
so you can see what has been imported into the scripter.
Additionally, the help supports switching between English and German,
which can be configured via the inifile (use the option language=en or language=ger).

Other Changes:

--Ruler flickering fixed: Thanks to feedback from staratel20,
I’ve resolved the flickering issue by implementing double buffering.
New property for Ruler: The Ruler component now has a new property called ShowMarker (boolean),
allowing you to enable or disable markers via the Object Inspector.
--Pan functionality using the middle mouse button: This feature has been implemented,
but it’s still slightly inaccurate. I’ll fix this once I get a mouse with three buttons for testing.
--Hints: These will be improved once the application becomes multilingual.

Bugs:
There are probably still several bugs. I wasn’t able to test the entire application step by step,
as it’s very time-consuming. If you find any issues, please report them, and I’ll fix them.

Examples:
In the directory data/PascalScripts/interactive, you’ll find some example scripts.
These demonstrate basic functionalities like dialogs (e.g., OpenFile),
creating and manipulating GraphicObjects, and more.

Here’s a short video showing the updates:
https://www.hackcad.com/maindownloads/LazCAD_Scripter_Help.mp4

Thank you all for your support and feedback!

Best regards,
Maurog.

PS: The download links from the first post are still up to date.
« Last Edit: November 20, 2024, 07:29:05 pm by maurog »
And yes, Lazarus is definitely a beast – it comes with everything you need, but sometimes also more than you expect. 😅 (Chat-GPT)

maurog

  • New Member
  • *
  • Posts: 38
New Version Uploaded
« Reply #55 on: November 21, 2024, 06:54:43 am »
In the latest version of LazCAD, a bug related to the "ShowRulerMarker" flag in the Object Inspector has been fixed. An exception occurred when toggling the ruler marker visibility via the Inspector. This issue has now been resolved. Additionally, a new file has been uploaded.
And yes, Lazarus is definitely a beast – it comes with everything you need, but sometimes also more than you expect. 😅 (Chat-GPT)

zamtmn

  • Hero Member
  • *****
  • Posts: 646
Re: LazCAD – First Release!
« Reply #56 on: November 21, 2024, 01:12:08 pm »
Hi!
CADSys4 support splines? hatchs? arc segments in polylines? blocks? raster images? line types?

maurog

  • New Member
  • *
  • Posts: 38
CADSys4
« Reply #57 on: November 21, 2024, 04:31:47 pm »
Hi

BSplines: Yes (TBSpline2D).

Hatchs: No. CADSys4 manages Pen and Brush properties via Layers.
This means that entities automatically inherit the Pen and Brush properties of their parent layer.
However, I’ve modified the library so that entities now also have their own Pen and Brush properties.
Users can decide (via the Object Inspector) whether these properties should be taken from the layer or use their own settings.
For closed entities, BrushColor and BrushStyle can be set.
As far as I know, programs like AutoCAD load Hatch patterns from external files.
CADSys4 doesn’t support this functionality.

Arc segments in polylines: No.

Blocks: Yes.

Raster images: Yes. The original library supports Bitmap files.
With minimal effort, this could be extended further because FPC/Lazarus offers great support for this.

Line types: Not directly. However, the library contains a Decorative Pen Object,
which can be used to create custom line types. Here’s the author’s description:
Quote
This class defines a decorative pen, that is a special Windows pen 
   that can have any pattern. The pattern is defined by a string of bits like 
   '1110001100', where a one represents a colored pixel and a zero 
   represents a transparent pixel. Because a decorative pen is associated with 
   a layer, you can manage it better. 
   <B=Note>: The decorative pen uses LineDDA functions to draw lines and 
   can only be used for lines and polylines (no ellipses are drawn using 
   the pattern). Redrawing the image will be slower, so use it only where necessary. 

Theoretically, this could be applied to ellipses since they are also made up of lines.
However, as the author mentions, the performance would be slower. (I haven’t tested this myself.)

TDecorativePen (definition):

Code: Pascal  [Select][+][-]
  1. TDecorativePen = class(TObject)
  2.   private
  3.     fPStyle: TBits;
  4.     fCnv: TCanvas;
  5.     fCurBit: Word;
  6.     fStartPt, fEndPt, fLastPt: TPoint;
  7.  
  8.     procedure SetBit(const Idx: Word; const B: Boolean);
  9.     function GetBit(const Idx: Word): Boolean;
  10.     function GetMaxBit: Word;
  11.     procedure CallLineDDA;
  12.   public
  13.     constructor Create;
  14.     destructor Destroy; override;
  15.     {: This method is used to make deep copy of the object by obtaining state
  16.        informations from another.
  17.  
  18.        <I=Obj> is the object from which copy the needed informations.
  19.     }
  20.     procedure Assign(Source: TObject);
  21.     {: Move the pen for the canvas <I=Cnv> to the position <I=X,Y>.
  22.     }
  23.     procedure MoveTo(Cnv: TCanvas; X, Y: Integer);
  24.     {: Move the pen for the canvas <I=Cnv> to the position <I=X,Y>.
  25.        This will not reset the current pattern bit. It is useful
  26.        when you are drawing a shapes made by segment.
  27.     }
  28.     procedure MoveToNotReset(Cnv: TCanvas; X, Y: Integer);
  29.     {: Draw a line using the current pattern and color to the position <I=X,Y>.
  30.     }
  31.     procedure LineTo(Cnv: TCanvas; X, Y: Integer);
  32.     {: Draw a polyline using the current pattern and color.
  33.        <I=Pts> are the points of the polyline and <I=NPts> is the number of points.
  34.     }
  35.     procedure Polyline(Cnv: TCanvas; Pts: Pointer; NPts: Integer);
  36.     {: Specify the pattern for lines.
  37.        The pattern is defined by a string of bits like
  38.        '1110001100', in which a one rapresent a colored pixel and a zero
  39.        rapresent a transparent pixel. By using this pen the redrawing of the
  40.        image will be slower, so use it only where necessary. Because a decorative
  41.        pen is associated to a layer you can manage it better.
  42.     }
  43.     procedure SetPenStyle(const SString: String);
  44.     {: Contains the pattern for lines.
  45.        The pattern is defined by a string of bits like
  46.        '1110001100', in which a one rapresent a colored pixel and a zero
  47.        rapresent a transparent pixel. By using this pen the redrawing of the
  48.        image will be slower, so use it only where necessary. Because a decorative
  49.        pen is associated to a layer you can manage it better.
  50.     }
  51.     property PenStyle[const Idx: Word]: Boolean read GetBit write SetBit;
  52.     {: Contains the pattern length.
  53.     }
  54.     property PatternLenght: Word read GetMaxBit;
  55.   end;
  56.  

Here’s a short video demonstrating blocks, raster images, and brush properties in action.
https://www.hackcad.com/maindownloads/LazCAD_Blocks_RasterImage.mp4


PS. Here is another open-source CAD application based on CADSys4.
You might find useful code that could be of interest for your project.
You can check it out on SourceForge
https://sourceforge.net/projects/tpx/
And yes, Lazarus is definitely a beast – it comes with everything you need, but sometimes also more than you expect. 😅 (Chat-GPT)

zamtmn

  • Hero Member
  • *****
  • Posts: 646
Re: LazCAD – First Release!
« Reply #58 on: November 21, 2024, 05:41:41 pm »
Thanks for the clarifications. I was referring to the real capabilities of DXF, not the surrogates provided by GDI\LCL (hatch\linetypes)

maurog

  • New Member
  • *
  • Posts: 38
Re: New LazCAD Version Available
« Reply #59 on: November 22, 2024, 08:12:35 pm »
Hello everyone,

I’ve uploaded a new version of LazCAD. Here are the main updates:

RuntimeScripter: The scripter is now integrated.
Limitation:
The ScripterIDE currently does not support multi-line comments in the {...} format. When importing code from Delphi, issues may occur. However, single-line comments in the // format are supported without any issues.


Simple Help: A basic HTML help system with multiple pages has been added.
It’s not complete yet but includes an overview of the RuntimeScripter functions,
so you can see what has been imported into the scripter.
Additionally, the help supports switching between English and German,
which can be configured via the inifile (use the option language=en or language=ger).

Other Changes:

--Ruler flickering fixed: Thanks to feedback from staratel20,
I’ve resolved the flickering issue by implementing double buffering.
New property for Ruler: The Ruler component now has a new property called ShowMarker (boolean),
allowing you to enable or disable markers via the Object Inspector.
--Pan functionality using the middle mouse button: This feature has been implemented,
but it’s still slightly inaccurate. I’ll fix this once I get a mouse with three buttons for testing.
--Hints: These will be improved once the application becomes multilingual.

Bugs:
There are probably still several bugs. I wasn’t able to test the entire application step by step,
as it’s very time-consuming. If you find any issues, please report them, and I’ll fix them.

Examples:
In the directory data/PascalScripts/interactive, you’ll find some example scripts.
These demonstrate basic functionalities like dialogs (e.g., OpenFile),
creating and manipulating GraphicObjects, and more.

Here’s a short video showing the updates:
https://www.hackcad.com/maindownloads/LazCAD_Scripter_Help.mp4

Thank you all for your support and feedback!

Best regards,
Maurog.

PS: The download links from the first post are still up to date.
And yes, Lazarus is definitely a beast – it comes with everything you need, but sometimes also more than you expect. 😅 (Chat-GPT)

 

TinyPortal © 2005-2018