With C# i am trying to create a grouped hole with a pattern in Microstation Connect v10 update 14. So far with no success.
Because a grouped hole does not have the ClosedElement interface i cannot use the SetPattern method.
Creating a grouped hole without a pattern is succesful:
// Create some complex elements: outermost and holes. All have property NotFilled and are on the same level var outermost = Application.CreateComplexStringElement1(ref elementArray); var holes[] = new Element[] { Application.CreateComplexStringElement1(ref elementArray) };
foreach (var hole in holes) mdlElmdscr_initOrAddToChain(&outEdPP2, hole.MdlElementDescrP());
mdlElmdscr_createShapeWithHoles(&outEdPP2, outermost.MdlElementDescrP(), holeEdP);
// Create element var groupedHole = Application.MdlCreateElementFromElementDescrP(outEdPP);
// Add to the designfile Application.ActiveModelReference.AddElement(groupedHole);
// Create pattern params e.g. var patternParams = new PatternParams(); patternParams.PrimaryAngle = Math.PI/4; patternParams.PrimarySpacing = 20.0; patternParams.Modifiers = PatternParamsModifierFlags.Angle1 | PatternParamsModifierFlags.Space1;
var result = mdlPattern_addAssociative(&outEdPP2, -1, -1, ref patternParams, 0, 0, 0, MicroStationGlobals.Instance.Application.ActiveModelReference.MdlModelRefP());
result is 0 (SUCCESS). outEdPP2 will have another value.
A grouped hole does appear in the designfile, but it has no pattern.
In MicroStation the property 'Pattern' says 'None', but I can create it manualy.
Any help would be appreciated.
leonardk said:i am trying to create a grouped hole
Why not use the .NET GroupedHoleElement? See DgnPlatformNet help doc.
GroupedHoleElement
leonardk said:Because a grouped hole does not have the ClosedElement interface i cannot use the SetPattern method
What about GroupedHoleElement.AddPattern?
GroupedHoleElement.AddPattern
See SDK example ..\Elements\ManagedToolsExample.
..\Elements\ManagedToolsExample
Regards, Jon Summers LA Solutions
Good morning,I have a problem with creating PatternArea on an object of type GroupedHoleElement,I would like to create a groupedHole like this:
the Microstation version is the following: Microstation CONNECT Edition Update 12 - Version 10.12.00.40.Given that I have already searched for a solution or examples in the SDK example .. \ Elements \ ManagedToolsExample and I have not found anything about it, I report below the code I wrote in C #.
GroupedHoleElement groupedHoleElement = currElement as GroupedHoleElement;PatternParams patternParams = new PatternParams ();patternParams.CellName = "A0A"; <- This field must contain the name of a model from the tmplate.cel library linked to the working filepatternParams.PrimarySpacing = 1patternParams.SecondarySpacing = 1patternParams.PrimaryAngle = 45patternParams.Scale = 1;
DwgHatchDefLine dwgHatchDefLine = new DwgHatchDefLine ();dwgHatchDefLine.Angle = 45;
DwgHatchDefLine [] dwgHatchDefLines = new DwgHatchDefLine [1];dwgHatchDefLines [0] = dwgHatchDefLine;
groupedHoleElement.AddPattern (patternParams, dwgHatchDefLines, 0);
The code is executed without errors, only that in the output the selected element has no pattern,would you have a working example in c #?
Thanks so much,
best regards
Salvio
salvatore montella said:patternParams.PrimarySpacing = 1patternParams.SecondarySpacing = 1patternParams.PrimaryAngle = 45
With C# and C++, dimensions are expressed in Units of Resolution (UORs). Angles are expressed in radians. The current dimensions for your pattern are too small to see.
Multiple your dimensions by UORs-per-Master Unit, which you can obtain from a DgnModelRef or DgnModel. Convert degrees to radians using Application.Radians().
DgnModelRef
DgnModel
Application.Radians()
salvatore montella said:groupedHoleElement.AddPattern
When you change an element, use its ReplaceInModel() method to persist it.
ReplaceInModel()
Hi Jon, Thanks for answering me,I modified the code following your instructions,but unfortunately it fails on the statement groupedHoleElement.ReplaceInModel (groupedHoleElement);
Here is the error message and stack:
Bad StatusInt: 32768
at Bentley.DgnPlatformNET.StatusHandler.ThrowStatusException(String statusType, Int32 status) at Bentley.DgnPlatformNET.StatusHandler.HandleStatus(Int32 status) at Bentley.DgnPlatformNET.Elements.Element.ReplaceInModel(Element toReplace) at Ides.Plugin.ThematicPlan.Controllers.PatternController.SetPatternOnSpace(Element element, IDgnECInstance item) in C:\V8i Projects\IDES_2.0\Ides.Plugin.ThematicPlan\Controllers\PatternController.cs:line 266
Do you have any idea what "Bad StatusInt: 32768" means?
Thank you
Hi Salvatore,
I think it's seriously bad idea to ask twice about the same issue: Here, where you steal 2 years old discussion and start to discuss a similar, but not the same, topic. And you also posted this new question. Really, how anybody can understand what discussion is "active one" now and to invest time to reading ans answering?
Also, please respect the best practices and to use Insert > Insert code tool when you want to share a code snippet. To read code, posted as plain, not formatted properly, text, is annoying.
Regards,
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point
Hi Jan,forgive me, it won't happen again in the future.GreetingsSalvio
salvatore montella said:C:\V8i Projects
The original post was discussing MicroStation CONNECT. You appear to be developing with MicroStation V8i.
Jan Šlegr said:you also posted this new question
I'm as confused as Jan. I suggest that you continue this discussion in that new post.
Please confirm the version of MicroStation that you are using.
Hi Jon,"C: \ V8i Projects ..." is just the name of the directory where I downloaded the source code.I confirm that the Microstation version is Connect Update 12 - Version 10.12.00.40.Thanks so muchSalvio