AutoCAD Map 3D Developer
Welcome to Autodesk’s AutoCAD Map 3D Developer Forums. Share your knowledge, ask questions, and explore popular AutoCAD Map 3D Developer topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Generate graphics with from forms

6 REPLIES 6
Reply
Message 1 of 7
thomas.pfarrwaller
769 Views, 6 Replies

Generate graphics with from forms

Hi,

I want to generate graphics from a API-Button in a Map 3D form. Is this possible?

The goal is to choose an object in the form and generate the graphics in the map with some parameters (ex. extension of the object).

So I would like to use the geometry of the object and I want to use the same parameters as I have in "advanced generate graphics" dialogue (easting, northing, with, heigth).

Thank you for some ideas.

6 REPLIES 6
Message 2 of 7
drewbb
in reply to: thomas.pfarrwaller

It can be done.

 

Check out the developer samples:

C:\Program Files\Autodesk\AutoCAD Map 3D 2013\Development\Samples

 

16_Dialog_Button will show how to create an API-Programmable Control on a form.

135_GenerateGraphics will show how to generate graphics.

 

Some notes:

1.  GraphicsGeneratorFactory.Instance is obsolete.  Instead, use Application.Services.GetService<IGraphicsGenerator>().

2.  Create an Autodesk.Map.IM.Graphic.Polygon to represent the area within which you want to generate graphics.  Perhaps you can get the bounding box of the feature in the form and create a polygon based on those extents.

3.  Use IFilterSetter to then apply the polygon as the extents for the graphics generation.

 

Here's some code:

 

IGraphicsGenerator gg = Application.Services.GetService<IGraphicsGenerator>();

//Confirm that gg.DisplayModel is not null

IFilterSetter filterSetter = FilterSetterFactory.Create(gg.DisplayModel);
filterSetter.OnlyOnTopobaseLayers = false;
filterSetter.TransformCoordSysInFilter = true;

//Somehow get the extents of the area within which you want to gg

var polygon = new Polygon
                    {
                        new LinePoint(SomeMinPoint.X, SomeMinPoint.Y),
                        new LinePoint(SomeMaxPoint.X, SomeMinPoint.Y),
                        new LinePoint(SomeMaxPoint.X, SomeMaxPoint.Y),
                        new LinePoint(SomeMinPoint.X, SomeMaxPoint.Y),
                        new LinePoint(SomeMinPoint.X, SomeMinPoint.Y)
                    };

filterSetter.ApplyViewport(polygon);

//Set the progress bar, draw, reset the progress bar, and dispose per the 135 code sample
Sincerely,
Drew Burgasser, P.E.
CAD Masters, Inc.
www.cadmasters.com
Message 3 of 7

Hi Thomas,

 

Did you check the refence code / post by Drew here ?

Hope that helps you in achieving what you want.

 

Thanks,

 



Partha Sarkar
Developer Technical Services
Autodesk Developer Network

Message 4 of 7

Hello,

 

additional question about the displaymodel.

 

I want to change the display model from "EBL_ALKIS__schwarz/Weiss" to  "EBL_ALKIS_farbig"

and use following source:

 

Dim gg As IGraphicsGenerator = GraphicsGeneratorFactory.Instance

 

gg.DisplayModel.Definition.Name = "EBL_ALKIS_farbig"

 

If gg.DisplayModel Is Nothing Then

Me.Application.MsgBox("No Display Model set")

Return

End If

 

But the flyouts from gg.DisplayModel show all the time "EBL_ALKIS__schwarz/Weiss"

 

Did you have an idea?

Regards Bjoern

Message 5 of 7
drewbb
in reply to: bjoern.moeller

Hi:

 

I haven't tried this, but I would guess that you actually need to get the DisplayModel and not simply change the name of the currently assigned display model.  There's a display model repository interface - maybe you have to grab the display model from that?

 

Does this work?

string resourceId = gg.DisplayModelRepository.GetResourceIdForDisplayModelFileName("EBL_ALKIS_farbig");
gg.DisplayModel = gg.DisplayModelRepository.Load(resourceId); 

 

 

Sincerely,
Drew Burgasser, P.E.
CAD Masters, Inc.
www.cadmasters.com
Message 6 of 7
bjoern.moeller
in reply to: drewbb

Hi,

 

thanks for the tip.

I could handle this problem with your help .
Instead of the name of the display models I have used the path:
ResourceId = gg.DisplayModelRepository.GetResourceIdForDisplayModelFileName("\\MA22-AP-013\Topobase\Darstellungsmodelle\EBL_ALKIS_farbig\EBL_ALKIS_farbig.tbdm")

 

Now I have another problem .
I want to build a map 2000x2000 meters and pass the coordinate of the center.

I use AutoCAD Map 2012 and can not use the ifiltersetter.

 

Dim filterSetter As ifiltersetter = Topobase.Display.DisplayModelManagement.FilterSetterFactory.Create(gg.DisplayModel)
filterSetter.OnlyOnTopobaseLayers = False
filterSetter.TransformCoordSysInFilter = True


Can I use the DRAW command (VBSample135) with parameter "center-coordinate" and "width/height"?
Or did you know a better way?
Regards Björn  

Message 7 of 7
drewbb
in reply to: bjoern.moeller

Hi:

 

Why can't you use IFilterSetter in 2012?  It looks available to me.

 

If IFilterSetter is not working, perhaps you can first zoom to the area of interest and then generate graphics:

http://through-the-interface.typepad.com/through_the_interface/2008/06/zooming-to-a-wi.html

Sincerely,
Drew Burgasser, P.E.
CAD Masters, Inc.
www.cadmasters.com

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost