Cancel
Showing results for 
Search instead for 
Did you mean: 

Problem in Retrieve dimension method

Pioneer
Pioneer

Hi everyone,

I am trying to retrieve all dimensions in respect views using the following code. There is no complied error, but dimension is not retrieved. Anyone can suggest me how to retrieve dimension or if possible share sample code on that.

 

*C#-ST 10.

 

                // Add a new model link for the part
                ModelLink mdlLink = dDoc.ModelLinks.Add(parName);

                // Create the three main views and an iso view of the part
                Sheet sheet1 = dDoc.ActiveSheet;
                DrawingViews views = sheet1.DrawingViews;
                DrawingView frontView = views.AddPartView(mdlLink, ViewOrientationConstants.igFrontView, 1.0, 0, 0.3,
                PartDrawingViewTypeConstants.sePartDesignedView);
                DrawingView rightView = views.AddByFold(frontView, FoldTypeConstants.igFoldRight, 0.3, 0.3);
                DrawingView topView = views.AddByFold(frontView, FoldTypeConstants.igFoldDown, 0, 0);
                DrawingView isoView = views.AddByFold(frontView, FoldTypeConstants.igFoldDownRight, 0.3, 0);
                              
                // Automatically retrieve all dimensions // Not worked
                topView.RetrieveDimensions(true);
                frontView.RetrieveDimensions(true);

                // Assign a caption // Not worked
                topView.Caption = "Top View";
                topView.DisplayCaption = true;

~VPJ

8 REPLIES

Re: Problem in Retrieve dimension method

Solution Partner Phenom Solution Partner Phenom
Solution Partner Phenom

Hi @VPJ19,

your code works with my test part.

Maybe there are no dimensions to retrieve in your part.

Try retrieving dimensions with manually.

regards

JB
SE 2019, VS2017

Re: Problem in Retrieve dimension method

Pioneer
Pioneer

Hi @JB

Manully all dimension is retrieve for the same part.I have attached Zip file with demo part. Can you check this? May be I have missed something in that code.

Thanks.

 

~VPJ

Re: Problem in Retrieve dimension method

Gears Honored Contributor Gears Honored Contributor
Gears Honored Contributor

Hello @VPJ19

 

In the Part1.par inside the demo.rar you have attached, the part has no dimensions.

 

The following is working for me:

using SolidEdgeFramework;
using SolidEdgeDraft;

static class Module1
{
public static void Main()
{
SolidEdgeFramework.Application seApp = System.Runtime.InteropServices.Marshal.GetActiveObject("SolidEdge.Application");
SolidEdgeDraft.DraftDocument seDoc = seApp.ActiveDocument;
SolidEdgeDraft.DrawingViews seViews = seDoc.ActiveSheet.DrawingViews;

foreach (SolidEdgeDraft.DrawingView seView in seViews)
seView.RetrieveDimensions();
}
}

After adding some dimensions:

retriDim.png

Regards,

Tushar

Re: Problem in Retrieve dimension method

Pioneer
Pioneer

Hi @Tushar

 

Your code also not worked for me.May be something is wrong in my case.

 

In the Part1.par inside the demo.rar you have attached, the part has no dimensions.

A dimension is already given in demo.rar file part, still not worked. For same part manually all dimensions are retrieved. But using both code nothing will be happen. Please find links for more clarification.

 

https://drive.google.com/file/d/1GpfAJwqSPl0NnBhvTUkfZXA-kCB__Bwz/view?usp=sharing

 

Thanks.

demo1.PNG

Re: Problem in Retrieve dimension method

Gears Honored Contributor Gears Honored Contributor
Gears Honored Contributor

Oh, OK. sorry about the comment, there indeed are a couple of dimensions, one in the sketch and the other one is the height of the protrusion.

 

I am able to extract it using my code, see this video:

(view in My Videos)

Highlighted

Re: Problem in Retrieve dimension method

Solution Partner Phenom Solution Partner Phenom
Solution Partner Phenom

Hi @VPJ19@Tushar,

I found the reason...

My test program succeeded retrieving the dimensions. The Program uploaded from @VPJ19 did not. Both using the same part.

So I digged deeper to find the difference. Reason is the use of  the community SolidEdge.Interop library.

The method RetrieveDimensions() has a lot of optional parameters with predefined values. But othe than documented SolidEdge.Interop defines all booleans to false:

2019-01-03 18_33_33-RetrieveCommunityInterop.png

 

I used the Interop generated by Visual Studio. Here the dafaults are as documented in the help:

2019-01-03 18_33_33-RetrieveCOMInterop.png 

To get around this problem just define more parameters to get the desired result, for example:

 

topView.RetrieveDimensions(true,"ISO (mm)",true,true,true,false,true,false,false,false,false,true,false);          

P.S.: to display the view caption dont use the .Caption Property. This is deprecated  and not documented in Help. Instead use :

 

topView.CaptionDefinitionTextPrimary = "Top View";

 

regards

JB
SE 2019, VS2017

Re: Problem in Retrieve dimension method

Gears Honored Contributor Gears Honored Contributor
Gears Honored Contributor

Good catch @JB.

I too was wondering why @VPJ19 had specified the first Boolean argument when it was optional and the default value worked fine.

Re: Problem in Retrieve dimension method

Pioneer
Pioneer

 @JB ,@Tushar

 

Thanks a lot!!!! It's worked perfectly in both condition either used Interop (Argument required) or used draft. tlb (Optional argument). clarification is very good and also thanks for caption property.Smiley Happy

 

~VPJ