Cancel
Showing results for 
Search instead for 
Did you mean: 

Moving Sketch to Origin through programming

Creator
Creator

Hi Guys,

 

I'm new to Solid Edge programming and needed a little support.

 

I'm copying a sketch from draft to part document programmatically but it gets copied somewhere in the part file.

So, im trying to move the copied sketch to  a specific coordinate(lets say origin in this case) but not able to find any method or way to do it.

 

Does anyone has any idea or piece of code that could help in this regard?

 

Thanks in advance.

8 REPLIES

Re: Moving Sketch to Origin through programming

Gears Honored Contributor Gears Honored Contributor
Gears Honored Contributor

I can give you some hints since the code is not available handy.

You need to access a Profile, supposing that you are pasting using the Paste method.

 

The equivalent of a Draft sheet in the Part environment is the Profile which is declared as:

Dim seActiveSketch As Profile

 

and accessed as:

seActiveSketch = seDocPart.ActiveSketch

 

I think there is a Paste Method there assuming that you have previously copied the sketch from Draft.

 

~Tushar

www.SurfAndCode.IN

 

Re: Moving Sketch to Origin through programming

Creator
Creator

Yeah.. I'm copying from Draft file and then pasting in the part file using Profile.Sketch() method.

 

But the issue is, it's getting pasted at some far away coordinates and I want it to be at some specific location or coordinates. So basically I want to move my sketch from one position to another.

 

 And I'm not able to find any methods in Sketch object to do so.

Re: Moving Sketch to Origin through programming

Gears Honored Contributor Gears Honored Contributor
Gears Honored Contributor

Give me a couple of hours, not having Solid Edge right now.

I had done this recently using a constant to 'paste to original coordinates' or 'at the selected point'.

I think in your case, it is defaulting to the first option and hence pasting at the same relative coordinates to the origin as the Draft sheet.

Re: Moving Sketch to Origin through programming

Creator
Creator
No worries.. Take your time.

Thanks for your replies Smiley Happy

Re: Moving Sketch to Origin through programming

Legend
Legend

sumit20,

 

if you paste the sketch,(X/Y) in Part  correlates with (X/Y) in Draft.

Zeropoint in Draft is the lower left corner.

 

regards

Gerald

Re: Moving Sketch to Origin through programming

Creator
Creator
Hi Gerald,

Yes you are right, I checked it yesterday and the sketch is getting pasted at the same coordinates as in the Draft file.

But i want to actually move the sketch to specific coordinates irrespective of where it gets pasted in the part file.
Manually we can use the move command I suppose, but how to do that through a program is what I'm struggling in.

Thanks.

Re: Moving Sketch to Origin through programming

Legend
Legend

Hi Sumit,

 

you can move each DrawingObject separately.

 

I don't know the background of your application, I do it this way:

  • creating a circle in the sketch (ConstructionElement)
  • add dimensions and relations (everything must be fixed)
  • add some attributes to the circle
  • paste the sketch
  • get circle by attributes
  • move the whole profile with circle.SetCenterpoint

Regards

Gerald

Re: Moving Sketch to Origin through programming

Gears Honored Contributor Gears Honored Contributor
Gears Honored Contributor

This involves some work but a great method to achieve what is required.

 

Sumit, I checked back my code and realized the constants were in fact created by me and not from Solid Edge.

Default coordinate pasting happens automatically but for a user-defined location for pasting, I gave the user the control by using the StartCommand for Paste.