DXF Viewer with Measure
DXF Viewer with Measure
DXF Viewer with Measure
DXF Viewer with Measure
DXF Viewer with Measure
DXF Viewer with Measure DXF Viewer with Measure DXF Viewer with Measure DXF Viewer with Measure DXF Viewer with Measure DXF Viewer with Measure DXF Viewer with Measure DXF Viewer with Measure
DXF Viewer with Measure DXF Viewer with Measure
DXF Viewer with Measure
Go Back  Xtreme Visual Basic Talk > > > DXF Viewer with Measure


Reply
 
Thread Tools Display Modes
  #1  
Old 12-16-2011, 05:21 PM
Gruff's Avatar
GruffDXF Viewer with Measure Gruff is offline
Bald Mountain Survivor

Retired Moderator
* Expert *
 
Join Date: Aug 2003
Location: Oregon, USA - deceased
Posts: 6,440
Default DXF Viewer with Measure


I am re-writing my old VB6 DXF viewer control in VB.NET Winforms.
It is looking pretty decent so I am near the finish.

Attached is a picture of my testbed app.

As we only need it to check parts that have been created to generate gcode for our laser it is limited to Points, Lines, Arcs, And Circles.

It has Point, EndPoint, Centers, and Intersections snaps for all entities and combinations of entities.

Measured output is displayed as Actual Point to Point plus Horizontal and vertical delta

Zoom Extents, Zoom Window, Pan and Mouse Wheel Zoom are fully functional. The last took a while to develop as I wanted the Zoom to be centered about the cursor position just as it is in Acad.

When it is done I might post it here if anyone has an interest.
Attached Images
File Type: png Simple DXF Viewer with Measure.png (50.3 KB, 130 views)
__________________
Burn the land and boil the sea
You can't take the sky from me


~T
Reply With Quote
  #2  
Old 12-16-2011, 07:05 PM
surfR2911 surfR2911 is offline
Contributor
 
Join Date: Oct 2009
Posts: 719
Default code interest

Quote:
When it is done I might post it here if anyone has an interest.
It looks like you have spent a not insignificant amount of time developing this - I'm sure such a posting would be appreciated.

Does it convert/export to any other AutoCAD-related format(s)?
Are there any plans for a collapsible panel to show the related gcode?
Reply With Quote
  #3  
Old 12-17-2011, 07:28 PM
jprg jprg is offline
Regular
 
Join Date: Dec 2008
Posts: 72
Default

Nice work.
Reply With Quote
  #4  
Old 12-28-2011, 12:35 PM
Gruff's Avatar
GruffDXF Viewer with Measure Gruff is offline
Bald Mountain Survivor

Retired Moderator
* Expert *
 
Join Date: Aug 2003
Location: Oregon, USA - deceased
Posts: 6,440
Default DXF Viewer Control

Attached is the control library project. PictureEx.

This contains the class Picturebox_WithRubberbands.vb derived from the picturebox class. The code was developed thanks to AtmaWeapon and his posts.

The PictureBox_2D_Cad.vb class derives from the above class and accesses among others the GeometrySelection.vb class which exist in large part due to Passel, OnError and numerous other early XtremeVBForum members.

The PictureEx library is a port from VB6 so it undoubtably could use improvement.
The immediate goal of the control was to provide a tool that allows viewing and measuring of DXF files containing only Points, Lines, Circles, and Arcs.

This may seem limited yet it fullfills my needs to view DXF files that were generated specifically to used for 2D G-Code translation.

If you want to expand on the supported geometry feel free.

---
Compile the PictureEx library then open and set the sample program to use the pictureEx library controls. Unzip the Cursor suite to a folder and point the sample program to them. I'm still looking for a better way to embed the cursors into PictureEx.

Enjoy.
Attached Images
File Type: png SnapChart.png (13.9 KB, 76 views)
Attached Files
File Type: zip PictureBoxEx.zip (28.8 KB, 157 views)
File Type: zip SimpleCAD.zip (21.2 KB, 148 views)
File Type: zip Cursors.zip (2.4 KB, 96 views)
File Type: zip Sample_DXF_File.zip (4.2 KB, 103 views)
__________________
Burn the land and boil the sea
You can't take the sky from me


~T

Last edited by Gruff; 10-20-2012 at 06:01 PM.
Reply With Quote
  #5  
Old 12-28-2011, 02:02 PM
surfR2911 surfR2911 is offline
Contributor
 
Join Date: Oct 2009
Posts: 719
Default Embedding cursors as resources

Quote:
I'm still looking for a better way to embed the cursors into PictureEx.
Better way to embed them then what?
Did you simply add them to the project as you would any other file, and then set their Build Action to Embedded Resource (using GetManifestResourceStream to retrieve them)?
What issues did you run into?

Here's some (possibly helpful) links:
MSDN: How to embed and access resources by using Visual Basic .NET
Understanding Embedded Resources in Visual Studio .NET
VB.Net: Set Custom Cursor from Resource File
vbHelper: Embed bitmap, text, and other resource files in a compiled application and use them in VB .NET
embed image (raw) in usercontrol without resource file vb.net
CodeProject: How to Embed Multiple Icons and Color/Animated Cursors in VS2010 VB Project Assembly as Native Win32 Resources

Microsoft .NET Framework Resource Basics

Using Resources in Visual Studio .NET

Many of the examples of embedding resources in VS.Net are C# instead of VB.Net, but you have to be careful of the differences (if you have difficulties it says to use Assembly.GetManifestResourceNames to check on the name of the embedded resource):
Embedded Resources difference between VB.NET and C# projects

..and if you decide to upgrade to animated cursors, it requires some special handling. The Code Project link above is helpful, but here's a sample to go by also:
Using Animated Cursors in .NET

Last edited by surfR2911; 12-28-2011 at 02:16 PM.
Reply With Quote
  #6  
Old 12-28-2011, 03:06 PM
Gruff's Avatar
GruffDXF Viewer with Measure Gruff is offline
Bald Mountain Survivor

Retired Moderator
* Expert *
 
Join Date: Aug 2003
Location: Oregon, USA - deceased
Posts: 6,440
Default

Initially I placed the cursors into the PictureEx resources and set them using:

Dim oMS As MemoryStream = New MemoryStream(My.Resources.CrossPt)
Me.Cursor = New Cursor(oMS)

The derived picturebox crashed when initializing stating it could not create the cursors.

This is not an issue in a standard winform.

Still looking into it.
Edit:
Tried it again and this time it loaded the cursors.
__________________
Burn the land and boil the sea
You can't take the sky from me


~T

Last edited by Gruff; 12-28-2011 at 05:31 PM.
Reply With Quote
  #7  
Old 01-22-2012, 04:56 PM
surfR2911 surfR2911 is offline
Contributor
 
Join Date: Oct 2009
Posts: 719
Default Getting things to run altogether..

I finally got around to trying to run your code in VB.Net 2010 and please excuse my befuddlement but things are not going well..

I'm assuming that PictureBoxEX must be run/built before SimpleCAD because when I open the Simplecad.sln file it says:
Quote:
The designer cannot process the code at line 57: Me.CAD1 = New PictureBoxEx.PictureBox_2D_Cad() The code within the method 'InitializeComponent' is generated by the designer and should not be manually modified
However if I open up PictureBoxEx.sln or PictureBoxEx.vbproj and try to run the code I get:
Quote:
A project with an Output Type of Class Library cannot be started directly.
In order to debug this project, add an executable project to this solution which references the library project. Set the executable project as the startup object
.

So basically what I think that means is a single solution has to be setup to referencing both projects in such a way that PictureBoxEX is run/compiled first and then SimpleCAD is run/built afterwards.

The semi-awkward part is both SimpleCad and PictureBoxEX both have their own separate solutions.

I assume this is because both were undergoing development separately, but I already tried creating a single (empty) solution and merging all the files into it but of course it didn't work. I obviously have to play around with configuring the solution in a certain way, but that's as far as I got.

All the coding I've done in VB.Net up to this point has involved a single solution so the intricacies of "massaging" two solutions merged together is not what I have experience with - is it possible to get everything melded into a single solution zip file with all files included and laid out properly the way the solution expects to find them.
Reply With Quote
  #8  
Old 01-23-2012, 08:45 AM
passel's Avatar
passelDXF Viewer with Measure passel is offline
Sinecure Expert

Super Moderator
* Guru *
 
Join Date: Jun 2003
Location: Upstate New York, usa
Posts: 8,024
Default

I can perhaps help you along, but there may be other issues.
If you open the PictureBoxEx project and build it, a dll file should be created in the bin/Debug (or Release depending on your project selection).
You can then close that project, and open the simpleCAD program.
If you right click on "SimpleCAD" in the Solution Explorer and select "Add Reference" you will get the "Add Reference" dialog.
Select the Browse tab and browse over to where the dll was built and select it (and OK).
You should now be able to open the form and not have a problem with the control reference.
In the code, search for the "/AAA/" and either put your cursors and dxf file in that location, or as Gruff suggests, change the AAA to point to where you put them.

I get a further error at this point, "Could not find a type for a name" in "Form1.resx", but I'm not really interested in this at the moment, so am not planning on pursuing it.
__________________
There Is An Island Of Opportunity In The Middle of Every Difficulty.
Miss That, Though, And You're Pretty Much Doomed.
Reply With Quote
  #9  
Old 01-23-2012, 04:44 PM
surfR2911 surfR2911 is offline
Contributor
 
Join Date: Oct 2009
Posts: 719
Default Thanks for the help..

Quote:
If you open the PictureBoxEx project and build it, a dll file should be created in the bin/Debug (or Release depending on your project selection).
Thanks for trying to help, but this build is exactly what is not happening.
I get stopped by the dialog that says:
Quote:
A project with an Output Type of Class Library cannot be started directly.
In order to debug this project, add an executable project to this solution which references the library project. Set the executable project as the startup object
Note: If you copy and paste this error into google most of the responses (that are all wrong --see solution below) are from ASP.Net and C# forums.

It does not build. It does not run. No dll is created.
I have nothing to reference in SimpleCad.
Even when I start out with an exe-type project and merge the PictureBoxEx project into it I get the same modal dialog box - but also a lot of errors (see screenshot below).

So I guess something needs to be done, either in the PictureBoxEx project or the PictureBoxEx solution to bypass this dialog box and allow the creation of the dll.

Note: I tried both the PictureBoxEx vbproj and the PictureBoxEx .sln and both gave me this same dialog box --which I think means it's looking to build an exe and maybe it need to be shifted/adjusted somehow so the visual studio ide knows it's building a standalone dll with no exe (necessarily) being involved.

edit1:
stupid stupid me!
I read through a whole bunch of forum articles that said to use F5 or green arrow to build.
Wrong!

This works for windows forms apps (built and run as exes), but not dll user controls that start out as a "Class Library" type (see dropdown beneath "Application Type", under Project properties).

So instead of pressing F5 or the green arrow you have to go digging around just to find the real way to build a user control dll.

Here's the secret--
Right click on the empty grey area to the right of any existing toolbars, then click on "Build" and magically the toolbar with the hidden build button appears (see attached screenshot).

Note: Under VB6 you actually "see" something when a user control successfully builds, but not under VB.Net. Had to go digging around the bin > Release folder to find it (the dll).

edit2:
Then I just had to (as passel explained) open the SimpleCad solution, add a reference to the PictureBoxEX dll, pressed F5, and got the SimpleCad form to appear!

Then I tried to load the the sample dxf file and got an error (most probably because it couldn't find the cursor resources -see attached screenshot).

edit3:
"that location" (the hard-coded path where SimpleCad expects to find the *.cur files) is not "\AAA\", but "C:\AAA\Cursors\"

It's all working now.
It looks a little different from the screenshot in post #1 so I'll attach an updated screenie.

Not let the tweaking begin..

Last edited by surfR2911; 01-23-2012 at 07:22 PM.
Reply With Quote
  #10  
Old 01-24-2012, 11:06 AM
passel's Avatar
passelDXF Viewer with Measure passel is offline
Sinecure Expert

Super Moderator
* Guru *
 
Join Date: Jun 2003
Location: Upstate New York, usa
Posts: 8,024
Default

Yes, I meant that searching for "\AAA\" would get you to the lines that needed to be changed. I'm doing a lot of Linux stuff, so did have the slashes backwards.
F5 has been used to run a program in the "IDE" since QBasic days, so I've always equated that to "Run".
I'm using VS2010 Pro, so it has a Build menu on the main menu, but I realize that if you're using the Express version, it doesn't, by default.
But if I were using the express version then I would normally select Build from the second item of the Debug menu (below the Run F5 menu selection), or just like adding a reference, simply right click on the project in the Solution Explorer and select Build or Rebuild from there.
With VS2010 Pro you can also do Ctrl-Shift-B to build.
Also, I did mention that the dll would be found under bin\Debug or bin\Release, depending on the configuration you had active. In my case, the Debug configuration was active.
__________________
There Is An Island Of Opportunity In The Middle of Every Difficulty.
Miss That, Though, And You're Pretty Much Doomed.
Reply With Quote
  #11  
Old 01-24-2012, 04:06 PM
surfR2911 surfR2911 is offline
Contributor
 
Join Date: Oct 2009
Posts: 719
Default VS.Net express 2010 tip..

Quote:
Yes, I meant that searching for "\AAA\" would get you to the lines that needed to be changed. I'm doing a lot of Linux stuff, so did have the slashes backwards.
No biggie.
I also have a Linux/Windows carryover thing - I got in the habit of using underscores instead of spaces in file names, not because the windows o/s cares, but because it caused such a pain when trying to do grep searching in Linux.
Quote:
But if I were using the express version then I would normally select Build from the second item of the Debug menu (below the Run F5 menu selection), or just like adding a reference, simply right click on the project in the Solution Explorer and select Build or Rebuild from there.
Thanks for the tip.
I read through a lot of tips for tweaking thinks inside the VS.Net IDE but they don't make the important distinction between the express and the pro versions.
Reply With Quote
  #12  
Old 01-24-2012, 06:23 PM
Gruff's Avatar
GruffDXF Viewer with Measure Gruff is offline
Bald Mountain Survivor

Retired Moderator
* Expert *
 
Join Date: Aug 2003
Location: Oregon, USA - deceased
Posts: 6,440
Default

Sorry for any confusion.

BTW I think there may be an issue with the decimal place state within the DXF file. Measuring it with Simple_CAD may bot report correctly.

I will post a new DXF when I can. Off work sick at the moment. Gout. Ouch.
__________________
Burn the land and boil the sea
You can't take the sky from me


~T

Last edited by Gruff; 01-30-2012 at 03:39 PM.
Reply With Quote
  #13  
Old 01-30-2012, 03:57 PM
Gruff's Avatar
GruffDXF Viewer with Measure Gruff is offline
Bald Mountain Survivor

Retired Moderator
* Expert *
 
Join Date: Aug 2003
Location: Oregon, USA - deceased
Posts: 6,440
Default

Thought I would explain some of the odder parts of the viewer control.

1) Entity Selection Zone
The selection zone is the area around each entity that a determines whether an entity can be picked. It is constant to the users viewpoint. Defaults to about 1/8" on screen regardless of the zoom factor.

2) OnPts (On Points)
OnPts are the user's cursor selection point translated to the model coordinates and then to the closest perpendicular point on the selected entity. These points are critical to help the system determine snap point selection. Indeed they make the whole selection process much more intuitve.

Imagine you select two intersecting circles with the intersect snap. There are two possible intersection points. The intersection closest to the selection OnPt is the one picked. Other snaps and entity combinations benefit from OnPts. You will see them passed into and back out of selection routines.

3) Fixed size feedback geometry.
Some feedback geometry: On Points (Represented as triangles), Measure Points (Represented as filled dots, Point Entities (Represented as Plus signs) and others are of a fixed size relative to the display regardless of zoom.

4) Line Widths
Line Width is turned off in the SampleCAD program since it has to deal with just about anyones geometry. Autocad users typically do not show their line widths in Autocad. They generally set it up with pen widths for hard copies Instead.
The viewer control will do line widths but there is some mucking about involved as Acad uses milimeters for linewidths. Lines with widths can disappear at really deep zoom scales

5) Linestyles
Linestyles are limited in this version to Solid,Hidden,Center, and Phantom.

6) Layer attributes
There are no default layer attributes in the viewer control
All entity attributes override layers. Basically layers are used here strictly for showing and hiding entities only.
__________________
Burn the land and boil the sea
You can't take the sky from me


~T

Last edited by Gruff; 01-30-2012 at 05:00 PM.
Reply With Quote
  #14  
Old 01-30-2012, 04:36 PM
surfR2911 surfR2911 is offline
Contributor
 
Join Date: Oct 2009
Posts: 719
Default 'plaining..

Thanks for those design insights.

I know the application was designed specifically to dovetail into the workflow needs of the company you work for, but it would be a shame if it didn't have enough "wiggle room" to be adapted more generally by others.

For me this would me having some kind of internal control panel where some of the "pre-defines" can be adjusted (maybe using a slider control) and read out to a config file.

That's were I'm working at tweaking things right now..another dxf sample file. maybe having two simple objects, and without the decimal place state issue, would be helpful as well whenever your gout is feeling better..
Reply With Quote
  #15  
Old 01-30-2012, 05:11 PM
Gruff's Avatar
GruffDXF Viewer with Measure Gruff is offline
Bald Mountain Survivor

Retired Moderator
* Expert *
 
Join Date: Aug 2003
Location: Oregon, USA - deceased
Posts: 6,440
Default

The complexity of the project and time constraints dictated what the control became.

As Passel pointed out in another post. There are an awful lot of simply great free dwg/dxf editors out there. Dessalt (Solidworks) made one in the hopes of cutting into Autodesks market share. It's called Draftsight. You can get it at Draftsight.com They have a version for Windows, Mac, and several flavors of Linux. Very proffessional IMHO.

I really have no interest in porting my old VB6 2D CAD package to VB.NET. I tossed it in the recycle bin some time ago.


RE the viewer control Some of the key values are exposed as properties that you can adjust.

For example:

Public Property DecimalPlaces As Byte = 3 'For inquiry output only
Public Property SnapPointDotSize As Single = 0.08
Public Property SnapPointDotBrush As Brush = Brushes.Red
Public Property SelectionTriangleSize As Single = 0.1
Public Property SelectionTrianglePen As Pen = Pens.White
Public Property SelectedEntityColor As Color = Color.White
Public Property PointEntitySize As Single = 0.16
Public Property SelectionZonePixelSize As Single = 10
Public Property OmitLineWidth As Boolean = False
Public Property Tangency_Healing_Tolerance As Single

What kind of predefines were you alluding to?

My knee is getting better but still stings something awful if I try to bend it too quickly.

I don't do CAD much these days so my drawing skills are rusty as the dickens.
I knocked the current sample out in CADKEY. which was the package I remembered the easiest. Peraonally I can't stand the Autocad interface.

Mostly these days I write enhancements for mecanical engineers who use 3D shaded soiidmodeling. If I have to create something I default to that.

Speaking of which have you seen Google's SketchUp? It has issues with model stability but the interface is a dream. A six year old can use it.
__________________
Burn the land and boil the sea
You can't take the sky from me


~T

Last edited by Gruff; 10-20-2012 at 06:36 PM.
Reply With Quote
  #16  
Old 01-31-2012, 02:08 PM
surfR2911 surfR2911 is offline
Contributor
 
Join Date: Oct 2009
Posts: 719
Default

Quote:
The complexity if the project and time constraints dictated what the control became.
Yes I had a feeling that was the case.
Quote:
I really have no interest in porting my old VB6 2D CAD package to VB.NET. I tossed it in the recycle bin some time ago.
This is a good thing. VB6 and VB.net should basically be considered two different languages in my opinion. However, when doing a portover from one language to another it can give the opportunity to re-think..re-imagine..reconsider what could be done.

As regards free standalone dwg/dxf editors:
Are any of them open source?
Not many I imagine that are written in VB.Net.
If you don't find some VB.Net useable code you can use then you end up being held hostage by those that hold the proprietary closed source code.
Quote:
I knocked the current sample out in CADKEY. which was the package I remembered the easiest. Personally I can't stand the Autocad interface.
Mostly these days I write enhancements for mechanical engineers who use 3D shaded soiidmodeling. If I have to create something I default to that.
I am familiar with Cadkey, but I also thought the Simplecad usercontrol had some passing familiarity with Powerstation (although of course without editing capabilities).

Speaking of Dessalt, don't they also make the CATIA line of products.

I used to know an engineer who worked for a a sub-contractor of Freightliner on Swan Island (which uses CATIA extensively to design their WesternStar line of truck parts).

He gave me a copy of the software he used at work.
Of course the software has a peculiar file handling scheme.
Basically it you try to open a CATIA file it looks for a CATIA-specific server (it thinks you want to "check out" a design from some project library shared by others).

I found it had a special function to access locally cached designs and was able to "fake out" the software into thinking the file on the hard drive was actually a locally archived file from the server and got the software to actually open up a few of the sample files he gave me (couldn't get it to save changes though).

I'm sorry to hear you are stuck just writing enhancements.
I imagine that must get pretty frustratingly limiting after a while.

Knowing of your distaste for the way AutoCad does things, though,
I had envisioned you developing a whole complete set of workflow solutions that could provide the missing pieces (and the "glue") between/among the various parts of the AutoCad product lines.

Personally I think AutoCad should have one large singular integrated "Suite" application where all the sub-products could basically be modules of this one integrated program.

But maybe that's not the way to milk all AutoCad licensees out of the maximum amount of money.

I just got around to exploring the publically exposed properties of the User Control (thanks for listing them).

The thing is how does a container application for a custom user control go about adjusting these properties using code in the container form?
I'm only beginning to explore writing code for manipulating data structures of custom user controls.

Lastly, regarding Sketch-up.
When Google swallowed @Last Software back in 2006, I was all over it,
but I thought,
"Great, Google is going to turn Sketch-up into an online version of Maya".
Guess what - it didn't happen!

Yeah, I know you're thinking - that was a really stupid assumption, but I had wanted someone to provide a lower cost version of Maya, and Google certainly has the resources.

The thing with Sketch-up - the free version is so crippled as to be unusable. Even the most basic needed features are reserved for Sketch-up Pro with costs $495.00 (do you have to be that greedy, Google?)

You can see all that it doesn't export/import to on this page:
http://sketchup.google.com/product/whygopro.html

And of course it doesn't import .OBJ or 3DS files at all!
You want to have animated texture meshes. Ha! Ha! Ha!
Yeah, Sketch-up is a joke.

I managed to add a control panel form into the Simplecad project.
I want to add either a menu button next to the Open menu button or a command button below the chklstlayers control but whenever I try to change anything at all on the form it gives me (for a build error):
Quote:
Error 1 Could not find a type for a name. The type name was 'System.Collections.Generic.Dictionary`2[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.Windows.Forms.Cursor, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
Line 372, position 5. C:\Users\x\Documents\Visual Studio 2010\Projects\VB.Net_Code\Gruff_Project\SimpleCad3\SimpleCAD\Form1.res x
..clicking on the error points to:
Code:
<data name="CAD1.CursorList" mimetype="application/x-microsoft.net.object.binary.base64">
    <value>
        AAEAAAD/////AQAAAAAAAAAEAQAAAPwBU3lzdGVtLkNvbGxlY3Rpb25zLkdlbmVyaWMuRGljdGlvbmFy
        eWAyW1tTeXN0ZW0uU3RyaW5nLCBtc2NvcmxpYiwgVmVyc2lvbj00LjAuMC4wLCBDdWx0dXJlPW5ldXRy
        YWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODldLFtTeXN0ZW0uV2luZG93cy5Gb3Jtcy5D
        dXJzb3IsIFN5c3RlbS5XaW5kb3dzLkZvcm1zLCBWZXJzaW9uPTQuMC4wLjAsIEN1bHR1cmU9bmV1dHJh
        bCwgUHVibGljS2V5VG9rZW49Yjc3YTVjNTYxOTM0ZTA4OV1dAwAAAAdWZXJzaW9uCENvbXBhcmVyCEhh
        c2hTaXplAAMACJIBU3lzdGVtLkNvbGxlY3Rpb25zLkdlbmVyaWMuR2VuZXJpY0VxdWFsaXR5Q29tcGFy
        ZXJgMVtbU3lzdGVtLlN0cmluZywgbXNjb3JsaWIsIFZlcnNpb249NC4wLjAuMCwgQ3VsdHVyZT1uZXV0
        cmFsLCBQdWJsaWNLZXlUb2tlbj1iNzdhNWM1NjE5MzRlMDg5XV0IAAAAAAkCAAAAAAAAAAQCAAAAkgFT
        eXN0ZW0uQ29sbGVjdGlvbnMuR2VuZXJpYy5HZW5lcmljRXF1YWxpdHlDb21wYXJlcmAxW1tTeXN0ZW0u
        U3RyaW5nLCBtc2NvcmxpYiwgVmVyc2lvbj00LjAuMC4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tl
        eVRva2VuPWI3N2E1YzU2MTkzNGUwODldXQAAAAAL
</value>
  </data>
Commenting out the form.res data in question gives the error:
A first chance exception of type 'System.NullReferenceException' occurred in SimpleCAD.exe
..and points to this line:
Code:
      .CursorList.Add("EndPt", New Cursor("C:\AAA\Cursors\EndPt.cur"))
My assessment of this (and it's just a shot in the dark). is that the way the user control is "bound" to the form.res is static and when it tries to update the form.res in a dynamic way (when adding a command button) the static binding is invalidated.

Note: I am externally referencing the pre-built PictureBoxEX.dll from the SimpleCad solution.
I still haven't figured out a way to merge the PictureBoxEX project with the SimpleCad project into a single solution where, when you go to build the solution, it dynamically re-generates the user control project and then build it into the SimpleCad project to provide a fully re-generated Simplecad exe.

Researching the "type name" error (which has to do with classes) in the context of user controls, many of the forum threads I found pointed toward an error in serialization (but I don't know enough about such things to know if this is the case).

Last edited by Gruff; 10-20-2012 at 07:12 PM.
Reply With Quote
  #17  
Old 02-01-2012, 05:06 PM
Gruff's Avatar
GruffDXF Viewer with Measure Gruff is offline
Bald Mountain Survivor

Retired Moderator
* Expert *
 
Join Date: Aug 2003
Location: Oregon, USA - deceased
Posts: 6,440
Default

Most likely part of the problem is you are trying to modify the Sample_CAD program before you have a handle on the Viewer Control.

If you start a new clean winforms project and from the toolbox rightmouse and select 'Choose Items' to get the control browser dialog. (This can take quite a while)
From the dialog you select Browse and path your way to the Picturebox_Ex Project. then to the Bin\Debug folder. Select the Picturebox_Ex.dll. Press OK.

Picturebox_WithRubberbands and PictureBox_2D_Cad Controls should now show up in your toolbox.

Select the PictureBox_2D_Cad control from the loolbox and draw it on your form just as you would a Picturebox control.

You should not have to do anything else to use it other than to make sure to add the cursors to it from the form load event.

You access the properties exactly the same as you would with any control.
Since they are declared as Public they will show up in the controls properties
(See Attached Pic)

Add a button to the form. In the click event Access the Control's Open method. add
Code:
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click PictureBox_2D_Cad1.OpenDXF("<Your Path>\Sample.dxf") End Sub

Run the app. Click the button. The dxf file should load. Mouse wheel should zoom. Shift Left mouse should pan. Ctrl Left Mouse should window zoom.

If everything works as stated continue.
------------

<Have to stop now. I will get back to you today or tommorw with more on how to develop with imported dll source.>

------------

Okay back for a bit.
Attached is a zipped Development Project where the controls are flattened out inside the project. You should be able to place breakpoints and debug.

Unzip and load the project. Before you start though....

1) Right mouse in the toolbox and delete both Picturebox_Ex Controls if they are there.

2) Open up the project references and make sure that Picturebox_Ex is not referenced.

3) Check the toolbox. What ever toolbox section was last selected is where they will show up. You might want to add a new section called Custom Contols and make sure you have selected it.

4) To get the Picture_2D_Cad control to show up in the toolbox Build the entire project.

5) the Cursors are now included in the Dev Project Resources so you do not have to add them.

Have fun.
Attached Images
File Type: png New CAD Viewer Control on Form.png (114.6 KB, 45 views)
Attached Files
File Type: zip Picturebox_Ex_Dev.zip (45.1 KB, 83 views)
__________________
Burn the land and boil the sea
You can't take the sky from me


~T

Last edited by Gruff; 02-01-2012 at 06:24 PM.
Reply With Quote
  #18  
Old 02-02-2012, 03:53 PM
surfR2911 surfR2911 is offline
Contributor
 
Join Date: Oct 2009
Posts: 719
Default PictureBoxEX develops further..

Quote:
Most likely part of the problem is you are trying to modify the Sample_CAD program before you have a handle on the Viewer Control.
Yes, you are right.
I actually purposely bypassed wanted to deal with the Viewer Control because I didn't want to mess up all your work straightaway.
Quote:
If you start a new clean winforms project and from the toolbox rightmouse and select 'Choose Items' to get the control browser dialog. (This can take quite a while).
Waited an hour - never happened. I guess I will have to do a little tweaking of my visualstudio express environment...
Quote:

Attached is a zipped Development Project where the controls are flattened out inside the project. You should be able to place breakpoints and debug.
Thanks for the update. I think I will be researching more about usercontrols in VB.Net before I tackle modding your control.

I have, however, been reading a little about raising events and bubbling them up:
http://answers.google.com/answers/th...id/323258.html
http://stackoverflow.com/questions/1...s-user-control.
Of course being derived from an existing control it already has certain events, so the question arises which custom events, if any should be raised/created.

Part of the reason I am interested in your user control is to use it to do more exploration (in general) of VB.Net custom Usercontrols.
Your custom user control is my "guinea pig" to experiment and play around with (lucky you!).

One of the things that has to be considered when even thinking about designing a custom user control is demarcation.

There is a "line" between what should be handled by the user control and what should be handled by it's container (usually a form/winform).

Wherever the demarcation of functionality is drawn however, the custom user control and container form have to be able to talk to one another.
This creates an interface.
Not a visual interface, but a programming/developer interface.

Where the demarcation occurs ultimately, though, is a design decision.
Which leads us to a bigger picture discussion..
Reply With Quote
  #19  
Old 02-02-2012, 03:57 PM
surfR2911 surfR2911 is offline
Contributor
 
Join Date: Oct 2009
Posts: 719
Default Making big picture design decisions.

Note: this is a continuation of the post above so I don't exceed the forum post length limits - yes I know I can be very long winded at times..)

Normally before I sit down to code anything I have to make up a design document.
In large companies this can be a formal process involving one or more levels of bureaucracy and usually (and this is where things go horribly wrong) a committee.

Of course being a "lone wolf" programmer this simplifies things, because I don't have to write down my design document (as I'm sure you probably did not have a written design document).
It's only important for a lone wolf programmer to have a clear sense (in his head) of what needs to be accomplished before starting (but also, hopefully, a vision of what the final form, the end product, is going to look like).

Unfortunately, not all my projects have been lone wolf type.

As is the industry standard practice (thinking along the agile scum methodology) most programming is done in teams and I've had to adapt to working with others on projects as well.

It makes things an order of magnitude more difficult.

If even one other person shares a project, in any way, there has to be, what I call "the conference".

It's where you attempt to get the other party to "sign on" to your vision of the project (or at least agree not to actively fight you every step of the way).

Part of the agreement that has to be reached is having at least some vague notion of who the end user of what your designing is going to be.

Going back to the first post of this thread you said:
Quote:
..we only need it to check parts that have been created to generate gcode for our laser..
In terms of parts checking I can see two possible end users:
The first type of end user might be an engineer at a CNC machining company, which actually manufactures parts (either for themselves or outside clients).
That is probably Gruff's imagined end user.

For the second type of end user I can also envision some sort of a document control person at a design firm/company.

Designing things at large companies can involve the same sort of process as evolving code.
Like source code control where code is checkout to be worked on (creating a separate "branch"), the code eventually has to be re-merged into the "trunk".
This is the subversion/github model and many design firms use it for design control as well.

Most often there is a project administrator.
This person, if the project budget is tight, sometimes also acts in the role of document control person (as well riding herd over trunk mergers).

Said project administrator must make final approval before a design (for a part say) is sent out to be prototyped or manufactured.

Thus, using a viewer to check what's going out is part of quality control (making a mistake machining a large block of aluminum could be very expensive).
Note: The dxf file may only be part of a larger set of files sent out, including a Solidworks rendering and/org-code file.

The third user is could envision for a DXF Viewer is someone sitting in an Internet Cafe, sucking down his fifth venti mocha latte espresso for the day and he gets an email with a .DXF file attached.

Of course the cybercafe machine doesn't have a complete AutoCad suite installed so he goes to some review sites (using his social media savviness of course).

Right away he finds Gruff's VB DXF Viewer which not only has been recommended by several reviews with five stars, but has already been downloaded tens of thousands of times.

So he downloads the svelte portableapp version which allows him to not only view the dxf file but screenshot and share it among his Google+ and Facebook friends.

Unfortunately the Gruff DXF Viewer (which I will be privately designating as the "VB Vectors Viewer", because it may eventually support many more formats than just DXF) still needs some more polishing before
it is ready to receive it's dozens of "best in class" awards..

Last edited by surfR2911; 02-02-2012 at 05:08 PM.
Reply With Quote
  #20  
Old 02-02-2012, 04:32 PM
surfR2911 surfR2911 is offline
Contributor
 
Join Date: Oct 2009
Posts: 719
Default Imagineering of the user interface..

Continuation 3 - please read through my previous above two posts first if you haven't already done so..

So when thinking about the end product, I always concentrate on the UX (the user experience) first.

Here's were I have to make a confession.
I'm legally blind without my glasses (20/1000 vision).
As such I have the mouse pointer / cursor under windows 7 set to the largest size possible.

I'm sure that the engineers at Gruff's company all have 20/20 or better (20/10?) vision but consider the guy
sitting at the cybercafe computer - he may not.
It's not always easy to make/create a fully ADA complaint interface, but that doesn't mean
you should at least consider, for instance, low vision, people when setting design criteria.

In this regard the current way of managing cursor resources may fall a little short of ideal.
It has only one set of sizes.

One could argue that including any cursors in a project/control is less than ideal since Windows already comes with them (cursors/pointers0
and custom resource cursors only serve to "bulk up" the exe (which of course we want to be as svelte as possible for portable apps file sizing).

However, if they are running Windows, I'm going to assume they have a 4TB hard drive as their boot drive (because in
my owned high-minded super techie way I think every should be required to have this).

So the bulking up, in terms of increasing file size, doesn't mean that much as the fact that the user experience is degraded if the program/app being designed isn't "aware" of the needs of the low vision user and what he/she has set the cursor size to in the mouse part of the control panel.
There should be a way to "poll" windows to figure out what's going on there, and based on that either:
1.) Use the appropriate set of in-built windows cursors (better from an overall O/S resource management point-of-view)
OR
2.) Choose among the two or three embedded set of cursors that which mostly closely approximates the defined default cursor "theme-ing" in size.

The other low vision user experience helper is the way zooming is controlled and outwardly presented.

Right now (I'm guessing in the interest of having the custom user control be as encapsulated as possible), the Zoom Extents, Zoom Window, Mouse Wheel Zoom and even marquee selection rubber-banding, are all "built-ins".

I have played with this a little and the zoom extent centering
(aka "Zoom to be centered about the cursor position just as it is in Acad")
is actually a nice feature, but there's no reset to this view once you've been playing around except to reload the file.

There should be a button or other user interface way to rest the view back to "view-at-load".

There may also be a case where (for screenshot-ing purposes) you may want the view to be "thumbnail-ish" - where the part is centered in the viewport very tiny with a large amount of empty background space around it.
Don't readily see an easy/obvious way to do this at present.

The other thing from the view of a user interface developer is that the custom user controls zoom features are, in a certain sense "hidden".
From a screenshot you couldn't guess at the zooming capabilities or how they are accomplished.

Which begs the question, if I, as a user interface designer, want to "expose" the zooming (in a more visually obvious/intuitive way), how can I do so without the form container having some code that "talks" to the user control, essentially "negotiating" the zoom level.

Here's what I thinking - imagine a form-based "zoom panel" (situated maybe in a status bar or directly below where the user control is placed), which contains a slider similar to the one in the status bar of the
current Microsoft Office. Here's a screenshot:
http://media.techtarget.com/rms/misc/sedTip_figure1.png

The zoom slider is also pictured standalone of this accessible article page:
http://office.microsoft.com/en-us/wo...010102272.aspx

Wrapping up.. (and I know this is all a lot to take in and you may just be thinking - I just wanted to develop something simple for internal company use only - what did I get myself into by releasing it..sorry )
..one of the reasons that Microsoft "unburied" it from being tucked inside a ribbon, is that blind windows users complained that using their text-to-voice screen readers it was too difficult to detect the zoom percentage when zooming to a custom percentage level).

So one of the tweaks for the Viewer app (that I was thinking of) would place the "Zoom to extents centered" button next to this slider in a form-based zoom panel (which hopefully the user control can "sync" up with with by passing custom events between the form and the user control internally.

Hopefully,
(even if you may be ready to give up because things are looking like they may get way to complicated),
you will take a some time to think about what I've said in these posts and not become too discouraged.
Attached Images
File Type: jpg Mouse_themes_selection_dialog_screenshot.jpg (66.6 KB, 31 views)

Last edited by surfR2911; 02-02-2012 at 05:17 PM.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
DXF Viewer with Measure
DXF Viewer with Measure
DXF Viewer with Measure DXF Viewer with Measure
DXF Viewer with Measure
DXF Viewer with Measure
DXF Viewer with Measure DXF Viewer with Measure DXF Viewer with Measure DXF Viewer with Measure DXF Viewer with Measure DXF Viewer with Measure DXF Viewer with Measure
DXF Viewer with Measure
DXF Viewer with Measure
 
DXF Viewer with Measure
DXF Viewer with Measure
 
-->