Reply

Scan and draw Algorithm

Hi, I'm wondering if it's possible to write an algorithm, for example, for Solid edge to scan a existing sketch for a square and then draw a circle in it. Is this wishful thinking?

4 REPLIES

Re: Scan and draw Algorithm

[ Edited ]

Hi,

 

one could probably solve this task as follows:

 

  • Search the Relations2d collection of a Sheet or Profile object for perpendicular relations
  • We expect to find 4 of them
  • For each found perpendicular Relation2d object determine the related objects, which should be of type Line2d with equal lengths
  • Each Line2d object found should have its start point common with the start or end point of exactly one of the other 3 lines
  • Now we've found the 4 lines building up our square
  • The radius of the circle to inscribe is 1/2 of the line length
  • The center point of the circle to inscribe can be derived also (Pythagoras)
  • Now the circle can be created via Circles2d.Add(...)

 

Kind regards,
Wolfgang Kunert - www.wksyspro.de

Re: Scan and draw Algorithm

Thanks Wolfgang for your reply. My problem is made more complex because the sketch I want to work on is imported from autocad. This means there is no existing relationships. Is there a way for Solidedge to auto-detect and implement relationships?

Re: Scan and draw Algorithm

[ Edited ]

Martin Bernhard recently tried the AddAutoConstraints method of the Relations2d object, but without success.

 

https://community.plm.automation.siemens.com/t5/Solid-Edge-Developer-Forum/How-to-use-Relations2d-Ad...

 

 So you should find the 4 Line2d objects, building a square, on your own. When comparing coordinates you should consider to ignore absolute differences smaller than a given epsilon.

 

Kind regards,
Wolfgang Kunert - www.wksyspro.de

Re: Scan and draw Algorithm

[ Edited ]

Hi:

  

I have attempted such sqaure detection and subsequent drawing geometry using it, which is detailed in this tutorial:

Rectangle Centerlines

 

Check if this can be adapted for your case.

The executable for the program is on the page below.

  

~Tushar Suradkar

www.CADVertex.com