Quantcast
Channel: MicroStation Programming - Forum - Recent Threads
Viewing all 383 articles
Browse latest View live

Scroll through named fences in a Design file

$
0
0

Good day,

I was wondering what kind of code I would need to access MicroStation named fences.

I have created a program that counts cells in a particular active cell.

I have saved a number of named fences in my drawing, and would like to apply the same program to them, without having to manually select and activate a fence from the named fences.

What i would like to do would be something like this:

For Each mfence As Fence In ActiveModelReference.NamedFences scanFence()'already existing functionNext

the above code assumes that i can access the NamedFences as a collection, or array.

I found that the Fence object in MVBA has a ActiveDesignFile.Fence.GetFenceNames as a member, but i could only get a handle of the names, 

and could not actually get the fence object itself in order to perform the scan.

What is the proper way to do this.

Thanks in advance

Regards, 

Am using Windows 7, 64 bit. MicroStation V8i Select Series 3


How to check dimension text height

$
0
0

Hi, I have to run a check on a set of drawing to check dimensions. The drawings do not have a dimension style (style:none) and some of them have the text height taken from the text style, others have it specified in dimension dialogbox. How can i properly check if the dimension text height is set from the dimension style or from text style?

Thank you very much,

e.g.

[v8i VBA] Error in finding last row in Excel using VBA

$
0
0

Hi All,

I think this is bit of Excel related question than mvba...but any help on this will help me.

what I want to do is create error report in an Excel sheet using VBA. below is the sample code which creates excel in a given path, but I'm getting error while adding data to the created xls. below I have Highlighted the code where I 'm getting error. please suggest me.

Option Explicit
Private Sub CommandButton2_Click()
Dim Excel As Object
Dim book As Object
Dim sheet As Excel.Worksheet
Dim fName As String
Dim oSheet As String
Dim oSheet1 As String
'Dim xlApp As New Excel.Application

With CDialog1
'.CancelError = True
.Filter = "Microsoft Excel (*.XLS)|*.XLS"
.FilterIndex = 1
.DialogTitle = "Save File"
.FileName = TextBox3.Text
.ShowSave

End With
fName = CDialog1.FileName
Dim strFile As String
strFile = (TextBox3.Value)
If Len(strFile) = 0 Then Exit Sub
'Set Excel = CreateObject("Excel.Application")
'Set book = Excel.Workbooks.Add
Dim DirFile As String
DirFile = fName
If Len(Dir(DirFile)) = 0 Then
Set Excel = CreateObject("Excel.Application")
Set book = Excel.Workbooks.Add
oSheet = TextBox1.Text
oSheet = VBA.UCase(oSheet)
Set sheet = book.Worksheets.Add
sheet.Name = oSheet

' create headers in xls
sheet.Cells(1, 1).Value = "Date & Time"
sheet.Cells(1, 2).Value = "Project Name"
sheet.Cells(1, 3).Value = "Delivery Name"
sheet.Cells(1, 4).Value = "Stage No"
sheet.Cells(1, 5).Value = "QA Staff Name"
sheet.Cells(1, 6).Value = "Prod. Staff Name"
sheet.Cells(1, 7).Value = "DGN Name"
sheet.Cells(1, 8).Value = "Edge Match"
sheet.Cells(1, 9).Value = "Wrong Layer"
sheet.Cells(1, 10).Value = "Others"
sheet.Cells(1, 11).Value = "Vertcheck"
sheet.Cells(1, 12).Value = "Missing"
sheet.Cells(1, 13).Value = "Interpretation"
sheet.Cells(1, 14).Value = "XY Position"
sheet.Cells(1, 15).Value = "Z Position"
sheet.Cells(1, 16).Value = "Delete"
sheet.Cells(1, 17).Value = "% of Errors"
sheet.Cells(1, 18).Value = "Comments"
book.SaveAs fName
book.Close
Excel.Quit
Set book = Nothing
Set Excel = Nothing
' add data to xls

Dim lastRow As Long
Set Excel = CreateObject("Excel.Application")
Set book = Excel.Workbooks.Open(DirFile)
With book.Worksheets(oSheet)
Set sheet = book.Sheets(oSheet)

lastRow = sheet.Range("A" & sheet.Rows.Count).End(Excel.xlUp).Row + 1 "Here I am getting object doesn't support this property or Method"

sheet.Range("Date & Time" & lastRow) = VBA.Date$
sheet.Range("Project Name" & lastRow) = TextBox1.Text
sheet.Range("Delivery Name" & lastRow) = TextBox2.Text
sheet.Range("Stage No" & lastRow) = "2"
sheet.Range("QA Staff Name" & lastRow) = TextBox4.Text
sheet.Range("Prod. Staff Name" & lastRow) = TextBox3.Text
sheet.Range("DGN Name" & lastRow) = "STRIP-1"
sheet.Range("Edge Match" & lastRow) = "1"
sheet.Range("Wrong Layer" & lastRow) = "1"
sheet.Range("Others" & lastRow) = "1"
sheet.Range("Vertcheck" & lastRow) = "1"
sheet.Range("Missing" & lastRow) = "1"
sheet.Range("Interpretation" & lastRow) = "1"
sheet.Range("XY Position" & lastRow) = "1"
sheet.Range("Z Position" & lastRow) = "1"
sheet.Range("Delete" & lastRow) = "1"
sheet.Range("% of Errors" & lastRow) = "35%"
sheet.Range("Comments" & lastRow) = TextBox5.Text

End With

If MsgBox("One record written to oSheet. Do you want to continue entering data?", vbYesNo + vbCritical, "Caution") = vbYes Then
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox1.SetFocus
Else
Unload Me
End If
book.Save
Excel.Quit
Set book = Nothing
Set Excel = Nothing
End if
End Sub
Best regards,
Prasanna 

[V8i C#] IModelChangeEvents

$
0
0

Hello!

I have created C# .NET MicroStation Addin. I need to have some things done before model is deleted so I try to use Bentley.Interop.MicrostationDGN.IModelChangeEvents.

I have written ModelChangeEventsTest class that implements IModelChangeEvents interface:

using MSDGN = Bentley.Interop.MicroStationDGN;

class ModelChangeEventsTest : MSDGN.IModelChangeEvents
{
public void ModelChange(MSDGN.ModelReference theModel, MSDGN.MsdModelChangeType change)
{
if (change == MSDGN.MsdModelChangeType.dlModelChangeBeforeDelete)
{
Variables.MainForm.RemoveModel(theModel);
}
}
}

This is how I add the events to the application:

using MSDGN = Bentley.Interop.MicroStationDGN;
using MSSERVICE = Bentley.MicroStation.InteropServices;

public static MSDGN.Application MSApplication = MSSERVICE.Utilities.ComApp;
private MSDGN.IModelChangeEvents _modelChangeEvents = new ModelChangeEventsTest();
MSApplication.AddModelChangeEventsHandler(_modelChangeEvents);

The problem is that ModelChange method is never called. I have added breakpoint at the beginning of that method and is never hit. So... Have I misunderstood something or it simply does not work?

Thank you in advance

Drop a LineStringElement to a series of LineElement(s)

$
0
0

Hi all,

I have a that has lineStrings in it. I want to convert all the line strings into lineElement(s) corresponding to the constituent lineStringElement segments lengths and 

positions. I have done it manually using the break element,  "7-2" command. I want to find a way to do this programatically, as there are numerous LineStringElements in my drawing and it would take ages to complete.

I tried dropping the LineStringElement, but it always says " Nothing to drop", so I am not sure how to fix this.

Thanks

Exporting Named fences and Models to new file

$
0
0

Good day.

I have a file that I received from a third party who uses a different seed file to me, and i need to use a particular seed file with it.

So I opened a new file, with the proper/desired seed file. Then I referenced the original drawing, and cllicked "Merge With master" option.

However, I have two problems,

Lets call the first file File001.dgn, and the second file, File002.dgn

So at this point, File002.dgn has the proper seed file, as well as a number of named fences and views, and its default model contains the default model of File001.dgn, as intended.  File002.dgn DOES NOT have the named fences that were existing in File001.dgn, and DOES NOT have the same views.

I tried to import the views in File001.dgn into File002.dgn, but they are linked to the old file, and DO NOT update when I change anything in the default model of File002.

1. I need tobe able to import the views in File001.dgn into File002.dgn.

2. I need to be able to export the named fences in File001 to File002, whose models are identical and so the named fences should fall in the same places.

How can i do this in VBA. Re-doing the view or the named fences is out of the question.

Any assistance would be welcome.

Thank you in advance.

[v8i VBA] LocateCursor while ILocateCommandEvents_Dynamics

$
0
0

Is it possible to have the locate-cursor-style shown while the ILocateCommandEvents_Dynamics-Event is running?

I would like to let the user select elements. After selecting the frist one, the ILocateCommandEvents_Dynamics should run an show some guide-lines. 

The problem is that as soon as I call CommandState.StartDynamics the cursor-style changes. Setting the cursor back to the locate-cursor with CommandState.SetLocateCursor seems to disable the Dynamics-Event.

An quick example in VBA is attatched.

Microstation XM Edition Bentley Microstation DGN 8.9 Object Library missing methods

$
0
0

Good day all.

I have access to MicroStation v8i SS3 at work, but at home I use XM edition

In SS3, the Fence object has a .GetFenceNames member, which allows you to get an array of the names of the NamedFences in your design file.

My problem is that in XM Edition, this method does not exist, as Intellisense does not pick it up.

If i run it anyway, it gives me an error. Is there a way around this, can i reference the SS3 dll from XM?

Is there an MDL function that i can invoke to give me the list of named fences in the design file?

Thanks in advance


[V8i C++] mdlAssoc_createOrigin()

$
0
0

I'm looking at mdlAssoc_createOrigin() in an attempt to create an association between a line and a cell. The line is written into the model just prior to the association attempt:

ElementRef    m_lineElemRef=m_lineElm.GetElemRef();AssocPoint   assocPt;
StatusInt iStatus=mdlAssoc_createOrigin( &assocPt, NULL, NULL, m_lineElemRef->GetElemID() );
if ( iStatus == SUCCESS )
{
     printf("AssociationPt created, m_lastElemRef->GetElemID()=%ld\n",m_lineElemRef->GetElemID());
}
MSElement  testEl=*m_eehFirstSymbol.GetElementCP();
mdlAssoc_insertPoint( &testEl, &assocPt, 0, 1 );
m_eehFirstSymbol.ReplaceElement( &testEl );
m_eehFirstSymbol.AddToModel ( ACTIVEMODEL );

 I get the symbol (cell) written to the model with a Dependency Linkage, but the cell's display is "dashed" - representing there is something wrong with the association, I think. What is the proper way to achieve the association?

 

Thanks,

Bruce

De-compile old MS Basic file with NO bas file

$
0
0

I have an old Microstation Basic file that I am trying to decompile to fix the errors and move it forward to V8i.  I don't have the bas file to go with the ba file.  Can the ba file be decompiled by Bentley support??

Select all elements with handles Microstation V8i

$
0
0

Hi Guys,

I just want to select all elements in dgn displaying their vertices as shown in the figure.

Problem is i can't able to display the (dgn)element vertices while capturing the (tool)element using tool.

Reason for displaying the vertices is for snapping the capturing element to displayed vertex.

Requirement: while capturing the element user will pick one key in for displaying the dgn elements vertices for snapping purpose.

[v8i MC] mdlRefFile_beginAttachmentToModel default attachment scale setting

$
0
0

I am using mdlRefFile_beginAttachmentToModel and it is attaching my reference at 100:1 scale. When I interactively attach a reference it defaults to 1:1 (which is what I desire). How do I set the default attachment scale used by this function?

dockable form question

$
0
0

Hi, I am trying to learn how to create  addins in C# and so far I've been able to create a dockable form. The question I have is: how can I have only one instance? Because if I run the keyin command again it will create another form. I am learning C# in the same time so, maybe this is a simple thing that I am missing right now.

What I would like to achieve is, when keyin the commad, if the form exists(in case is minimized) to appear in normal window state on the screen; if it doesn't exists, just to create it. The code I am using is:

        public static void ShowMyForm(string unparsed)
        {
            pr = new MyForm();
            pr.NETDockable = true;
            Bentley.Windowing.WindowManager bwwm = Bentley.Windowing.WindowManager.GetForMicroStation();
            Bentley.Windowing.WindowContent bwwc = bwwm.DockPanel(pr, pr, pr.Text, Bentley.Windowing.DockLocation.Floating);
            bwwc.Show();
        }

Thank you and I appreciate any suggestion,

e.g.

MicroStation V8i re-using file positions after undo

$
0
0

Win7-32, uStn 8.11.05.17 and 08.05.00.64

hello world,

Has anyone come across different behaviour between MicroStation V8 and V8i as for Undo and file positions, like me?

Example: V8:
place line: filepos is 4000001, EOF is 4000002
ctrl-z or undo
place line: filepos is 4000002, EOF is 4000003

whereas V8i re-uses filepos (apparently Undo decreases some internal pointer, but not EOF)
place line: filepos is 4000001, EOF is 4000002
ctrl-z or undo
place line: filepos is 4000001, EOF is 4000002

EOF is not visible I think, somewhere in MicroStation, only through mdlfunctions
mdlModelRef_getEof or dgnCache_getEOF.

This has impact for applications supposing that some new element is written at the end of the file, like I remember was common practice in earlier times (and I have such a case at hand right now, it tries to read the element from this stored position a bit later, so: problems).

I suppose there is not an easy solution? (this application must keep track of positions of it's added elements in another way, but that is not so easy).

(Even, I'm now thinking, an mdlapp might record EOF, then start another app, then suppose the results reside from that recorded position. That would work in V8, but not always in V8i).

regards, Jan Willem

 

[v8i] default reference attachment scale setting

$
0
0

How do I set the default reference attachment scale (i.e. 1:10, 1:1, etc) without manually having to change it every attachment?


[V8i C++] using FileOpenDialogPreprocess() hook to save a DWG file as DGN format.

$
0
0

I've got a callback function for FileOpenDialogPreprocess() where I trap the "Save-As" dialog. How do I force a .DWG file (R2013) to be saved as a .DGN format file? I've tried setting fOpenParamsP->defFileId= DEFV8DGNFILE_ID, but all I get is the R2013 .dwg file saved out as R2010 .dwg file. Even when I pick .DGN from the drop down "types" list, it saves out as .dwg format.

 

Thanks,

Bruce

"Select by Attributes"-select by text node

$
0
0

I have a file with several multi lines of text - 14'(top line) CHEESE (SECOND LINE),8'(top line) CHEESE (SECOND LINE),14'(top line) FISH (SECOND LINE)

How do you use Select by attributes Select by text or text node to only choose “14’ CHEESE” text? I can only seem to key in a single line at a time. Either 14’ or CHEESE, but if you key in either of those you get the other text in the selection as well.

 

[V8 C++] CacheElem -- what is it for?

$
0
0

What is the purpose of the CacheElem class?  Here's its definition from <dgncache.h>...

struct CacheElem : public IElementRef
    {
private:
    virtual void MakeClassAbstract() = 0;
    };

It's an abstract class that is otherwise identical to an elementRef.  There's some subtlety of C++ that I've missed.  Why is this abstract class preferable to, say, an ElementRef const&?

[V8 C++] DgnCacheIterator Example?

$
0
0

Is there an example of using a DgnCacheIterator?

I'm puzzled because the default constructor (see<dgncache.h>) sets its state to iterate non-model elements.  I don't see a method to set its state to iterate graphic elements.  How would one use a DgnCacheIterator to iterate graphic elements in a model?

selectseries3 variable problem

$
0
0

hi ,

i am trying to link the workspace/users to folders inside of users forlder. eg  workspace/users/bob..... workspace/users/bill ect.

does anyone know the variable to set so it picks up the current logged on users name? so on microstation start up it doesnt have a list of all the different users but just one (that logged on user) 

_USTN_USER = $(_USTN_WORKSPACEROOT)users/ .....

is the varibale (_ENGINENAME)?

thanks in advance

Viewing all 383 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>