c# autocad dllimport by autocad version - c#

i have been using the the program from "Detecting entities under cursor while selection is running" By Philippe Leefsma located here1. it worked in ACAD2014 however now we are using ACAD2016. it will not work because of the DLLImport of acdb19.dll and autocad2016 needs acdb20.dll. Is there a way to make the program load eighter dll version? i tried using netload and assembly.loadfrom and neither worked.
Point Monitor callback

The DLL import is set at compile time so the best bet is to compile two versions for each release of AutoCAD.
Once the project is compiled, you could set up an autoloader by creating an application.bundle folder. this folder can be placed in c:\programdata\Autodesk\applicationPlugins. In the application.bundle folder, create a subfolder called Application and place the compiled .DLL file in there.
The loader is controlled with an XML file which should be named PackageContents.xml. Here's some example code for the xml file:-
<?xml version="1.0" encoding="utf-8"?>
<ApplicationPackage xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
Name="My AutoCAD App"
Description="Does something in AutoCAD"
Icon="./Application/MyIcon.ico"
Author="Paul Nelson">
<CompanyDetails Name="Paul Nelson"
Url="http://www.stackoverflow.com"
Email="myemail#email.com">
</CompanyDetails>
<Components>
<!-- define the min and max versions of AutoCA in the next line -->
<RuntimeRequirements OS="Win64" Platform="AutoCAD" SeriesMin="R19.0" SeriesMax="R22.0" />
<ComponentEntry
ModuleName=".\Application\MyApp.dll"
LoadOnAutoCADStartup="true"
LoadOnCommandInvocation="false"
AppDescription="This is assembly MyApp."
AppName="My AutoCAD App"
AppType=".NET">
<Commands GroupName="My Apps">
<Command Local="MYAPP" Global="MYAPP" />
</Commands>
</ComponentEntry>
</Components>
</ApplicationPackage>
One last tip - make sure the .dll filename does not contain spaces.

Related

Missing stylable field MvxExpandableListView_GroupItemTemplate

I've noticed the following MvxBind info message being output to logcat while debugging on Android:
Missing stylable field MvxExpandableListView_GroupItemTemplate
I've tried adding the MvxBindingAttributes.xml file from GitHub to the DroidProject\Resources\values folder and set the Build Action to AndroidResource. This causes a compiler error for each <declare-stylable> XML tag like:
Attribute "XXX" has already been defined
It's interesting because it claims MvxGroupItemTemplate is already defined when I compile, yet when I run the program a message is displayed saying it's missing.
What should I do to fix this?
I had the same problem this morning when updating to the latest version of Xamarin Studio. Fixed it for now by including this:
<?xml version="1.0" encoding="utf-8" ?>
<resources>
<declare-styleable name="MvxExpandableListView">
<attr name="GroupItemTemplate" format="reference"/>
</declare-styleable>
</resources>
In the Resources\values\attrs.xml file.

How to draw every characters with spritefont in monogame

I'm new to monogame, and I'm trying to make a .spritefont file in order to draw string with the font I choose.
Strings with English characters can show well on the screen, but I wish to draw strings in multiple languages, like Japanese and Chinese.
So, I tried to load all characters in a Multi Language Font "Microsoft JhengHei".
The font's first character is !(U+0021) and the last one is ○(U+FFEE).
But when I tried to compile the program, the compiler gave me an error:
.../Content/MyFont.spritefont : error : Importer 'FontDescriptionImporter' had unexpected failure!
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentException: CharacterRegion.End must be greater than CharacterRegion.Start
at Microsoft.Xna.Framework.Content.Pipeline.Graphics.FontDescription.set_CharacterRegions(CharacterRegion[] value)
And when I changed the ○ to 忮, MSBuild stucks and takes forever to proceed the content.
Code in MyFont.spritefont below:
<?xml version="1.0" encoding="utf-8"?>
<XnaContent xmlns:Graphics="Microsoft.Xna.Framework.Content.Pipeline.Graphics">
<Asset Type="Graphics:FontDescription">
<FontName>Microsoft JhengHei</FontName>
<Size>14</Size>
<Spacing>0</Spacing>
<UseKerning>true</UseKerning>
<Style>Regular</Style>
<CharacterRegions>
<CharacterRegion>
<Start>!</Start>
<End>○</End>
</CharacterRegion>
</CharacterRegions>
</Asset>
</XnaContent>
I searched for the solution for a few days but in vain, any help is appreciated.
I was not able to reproduce the steps of the accepted answer from J3soon in Monogame 3.7.1.
However in Monogame 3.7.1, it is not longer necessary to use the Custom Content Pipeline because the pipeline tool now natively contains a LocalizedFontProcessor.
My steps were :
Set the .spritefont Processor to LocalizedFontProcessor in the pipeline tool
In the .spritefont, include the path to the resx file.
In the .spritefont, replace Asset Type="Graphics:FontDescription" with Asset Type="Graphics:LocalizedFontDescription"
Rebuild the Content
I would have thought step #1 would have done #3 behind the scenes but for me it was necessary to do this both in the pipeline tool and the .spritefont file.
spritefont file
<?xml version="1.0" encoding="utf-8"?>
<XnaContent xmlns:Graphics="Microsoft.Xna.Framework.Content.Pipeline.Graphics">
<Asset Type="Graphics:LocalizedFontDescription">
<FontName>Arial</FontName>
<Size>16</Size>
<Spacing>2</Spacing>
<UseKerning>true</UseKerning>
<Style>Regular</Style>
<CharacterRegions>
<CharacterRegion>
<Start> </Start>
<End>~</End>
</CharacterRegion>
</CharacterRegions>
<ResourceFiles>
<Resx>..\Strings.fr.resx</Resx>
</ResourceFiles>
</Asset>
</XnaContent>
Content file
#begin MyFont.spritefont
/importer:FontDescriptionImporter
/processor:LocalizedFontProcessor
/processorParam:PremultiplyAlpha=True
/processorParam:TextureFormat=Compressed
/build:MyFont.spritefont
Since processing all 65 thousand characters takes too much time. We should only process the characters we are using.
So the easiest way is to make a MonoGame Custom Content Pipeline and load the characters we are using by some .resx files.
It took me so much time searching for this solution. So I'll post how did I succeed, hope it can help someone who has the same question in the future.
Step-by-step Tutorial
Create a Class Library.
Reference the MonoGame.Framework.Content.Pipeline.Portable package using NuGet. (Make sure you checked the Include Prerelease checkbox )
Download the LocalizationSample here and unzip the file.
Under LocalizationPipeline\ copy LocalizedFontDescription.cs and LocalizedFontProcessor.cs into the class library
Build the class library so it outputs a LocalizationPipeline.dll file.
Open Myfont.spritefont and change its Asset Type to LocalizationPipeline.LocalizedFontDescription
Then add the resources <ResourceFiles><Resx>..\strings.resx</Resx></ResourceFiles> (these files should contain the string we want to draw)
Open Content.mgcb and reference to LocalizationPipeline.dll
Set the MyFont.spritefont's processor to LocalizedFontProcessor
ReBuild the project.
MyFont.spritefont
<?xml version="1.0" encoding="utf-8"?>
<XnaContent xmlns:Graphics="Microsoft.Xna.Framework.Content.Pipeline.Graphics">
<Asset Type="LocalizationPipeline.LocalizedFontDescription">
<FontName>Microsoft JhengHei</FontName>
<Size>14</Size>
<Spacing>0</Spacing>
<UseKerning>true</UseKerning>
<Style>Regular</Style>
<CharacterRegions>
<CharacterRegion>
<Start> </Start>
<End>~</End>
</CharacterRegion>
</CharacterRegions>
<ResourceFiles>
<Resx>..\strings.resx</Resx>
</ResourceFiles>
</Asset>
</XnaContent>
Content.mgcb
...
#-------------------------------- References --------------------------------#
/reference:..\LocalizationPipeline.dll
#---------------------------------- Content ---------------------------------#
...
#begin MyFont.spritefont
/importer:FontDescriptionImporter
/processor:LocalizedFontProcessor
/build:MyFont.spritefont
...
Sources
Part 1 of Creating custom content importers for the MonoGame Pipeline
How to: Create a Localized Game
LocalizationSample (Thanks to #Groo for giving me this link.)

Wix File Association - Misunderstanding

I have an application and I want to use my own file extension that opens my application when double clicked.
I'm using Wix to build my installer and understand that I can make use of file association in my .wxs file. A snippet from the file currently looks like this:
<DirectoryRef Id ="INSTALLFOLDER">
<Component Id ="RBUpdate.exe" Guid="*">
<File Id="RBUpdate.exe" KeyPath="yes" Source="$(var.RBUpdate.TargetDir)RBUpdate.exe" />
<ProgId Id ="MyProgID" Description="RBUpdate data files" Advertise="yes">
<Extension Id ="rbu" ContentType="application/rbu">
<Verb Id ="open" Command="open" TargetFile="RBUpdate.exe" Argument=""%1""/>
</Extension>
</ProgId>
</Component>
</DirectoryRef>
<Feature Id ="ProductFeature" Title="RBUpdateSetup" Level="1">
<ComponentRef Id ="RBUpdate.exe"/>
</Feature>
This builds fine but, if I'm honest, I'm new to this and not quite quite sure what it does.
How do I create an instance of my created file type? The files I'm creating are not going to be as a result of running the application and they will be manually made externally to the application, which it will then load. I simply want to be able to make an xml file, name it with the .rbu extension, and have it open with my application.
I was very simply not renaming my xml files .rbu! This is a working example of how to use file association with wix anyway, to not completely waste time :L

ReSharper 9 Adding menu item action not working

Trying to update my resharper extension to work for 9.0, before I was just moving the dll into the plugins directory but now I need to figure out how to get nuget to work... I've been able to package the files, dll gets included in the nupkg but I think I have some namespace\id something something issues(not very familiar with .net) and it doesn't seem as if my actions.xml is even being read by resharper when I import the nuget package. The menu item isn't being added. Anwyays if anyone can give me any sort of advice on how to debug a nuget package or what might be going wrong would really really appreciate as I've been stuck on this for a few days now.
Actions.xml
<?xml version="1.0" encoding="utf-8" ?>
<actions>
<action id="yuval" text="L10N"></action>
<insert group-id="ReSharper" position="last">
<action-ref id="yuval" text="About Localization Helper"/>
</insert>
</actions>
AboutAction.cs
namespace JetBrains.Resharper.L10N
{
[Action(Id)]
public class AboutAction : IExecutableAction
{
public const string Id = "yuval";
public bool Update(IDataContext context, ActionPresentation presentation, DelegateUpdate nextUpdate)
{
return true;
}
public void Execute(IDataContext context, DelegateExecute nextExecute)
{
MessageBox.ShowMessageBox(
"Localization Helper\nYuval\n\nHelps Localize",
"About Localization Helper",
MbButton.MB_OK,
MbIcon.MB_ICONASTERISK);
}
}
}
nuget spec
<?xml version="1.0"?>
<package >
<metadata>
<id>JetBrains.Resharper.L10N</id>
<version>1.0.0.7</version>
<title>L10N</title>
<authors>Yuval</authors>
<owners>UW</owners>
<licenseUrl>https://myurl.com</licenseUrl>
<projectUrl>https://myurl.com</projectUrl>
<iconUrl>https://myurl.com/logo.png</iconUrl>
<requireLicenseAcceptance>true</requireLicenseAcceptance>
<description>Tool to help localize</description>
<releaseNotes>Summary of changes made in this release of the package.</releaseNotes>
<copyright>Copyright 2015</copyright>
<tags></tags>
<dependencies>
<dependency id="Wave" version="[1.0]" />
</dependencies>
</metadata>
<files>
<file src="..\bin\Debug\JetBrains.Resharper.L10N.dll"
target="dotFiles\"/>
</files>
</package>
The way actions are registered has changed in ReSharper 9. It's no longer done with actions.xml, but with interfaces on your action class. For example, to add an action to the ReSharper → Tools menu, you would do:
[Action(ActionId, Id = 1)]
public class AboutAction : IExecutableAction, IInsertLast<ToolsMenu>
{
public const string ActionId = "yuval";
// …
}
You also need to specify a unique value for Id. As of 9.1, this needs to be unique within your own extension (9.0 required it to be unique across the whole installation, including ReSharper itself and any other extensions).
Whenever you change the attributes or interfaces of an action, the extension needs to be reinstalled via nupkg (the actions are statically registered with Visual Studio, in the same way as a standard VS extension), but if just the implementation has changed, you can copy the dlls to the install folder, either manually, or via a small change to the .csproj.
You also need to make sure you've defined a ZoneMarker class. This declares that your action belongs to a zone, which is used to enable/disable functionality based on installed features and the current host (e.g. so Visual Studio specific extensions only work in VS and don't get loaded into dotPeek, etc.). You can find out more about Zones in the devguide, with this page providing useful info for defining a zone marker.
This thread should help, too.
Also, it's probably a good idea to name you dll and nupkg something other than JetBrains.ReSharper.(Whatever) to prevent any potential clashes with official dlls, and to prevent confusion as to where the dll comes from. The first part of the name is supposed to be your company's name (or personal name).

Trouble referencing a file in a visual studio project on a unit test

I'm having quite a bit of trouble in resolving an issue dealing with referencing a custom text file in my project. NOTE: the file contains text, but its of a custom type '.rit'
I'm currently building and running some test cases for a new application and one of them involves reading a file that resides in a sample folder of my project called 'TestFiles'. At first, I ran the test locally using the absolute path of the file and it ran with no issues. However, I am using TFS to check in my code and once the test runs in the server it fails immediately because it can't locate the file, which was obvious because I was using an absolute path to a file in my local drive, so I NEED to change how the test accesses this file to make it work both locally and on the server.
I've looked at a look of examples as I was looking for help but none seem to work... I've tried:
DeploymentItem:
[DeploymentItem(#"TestProject\TestFiles\test file.rit", "TestData")]
[TestMethod]
public void LoadFileTest()
{
//Assert.IsTrue(File.Exists("test file.rit"));
var obj = new obj();
var tstFile = #"TestData\\test file.rit";
var file = new StreamReader(tstFile);
obj.OpenRitFileInTextFormat(file);
}
The hierarchy of the file is: Solution\TestProject\TestFiles\test file.rit and I made sure to set the Copy to Output to "copy always"
Adding it as a Resource:
//[DeploymentItem(#"TestProject\\TestFiles\\test file.rit", "TestData")]
[TestMethod]
public void LoadFileTest()
{
//Assert.IsTrue(File.Exists("test file.rit"));
var obj = new obj();
var tstFile = Properties.Resources.test_file;
//this one throws an error however because it says the type of tstFile is now
//a byte[] instead of a stream reader
*var file = new StreamReader(tstFile);*
obj.OpenRitFileInTextFormat(file);
}
I'm not very experienced in this one, so I might be doing something wrong... If anyone could please enlighten me or give me some guidance as to where else I could look for help I would GREATLY appreciate it!
Thanks,
EDIT: I have found out my TestData folder I'm specifying to be copied in the DeploymentItem path is not being created/copied to the Out folder of the test run. I'm starting to think this is more of a settings file problem, here's the contents of my settings file:
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<!-- Configurations that affect the Test Framework -->
<RunConfiguration>
<!-- Path relative to solution directory -->
<ResultsDirectory>.\TestResults</ResultsDirectory>
<!-- [x86] | x64
- You can also change it from menu Test, Test Settings, Default Processor Architecture -->
<TargetPlatform>x86</TargetPlatform>
<!-- Framework35 | [Framework40] | Framework45 -->
<TargetFrameworkVersion>Framework40</TargetFrameworkVersion>
</RunConfiguration>
<!-- Configurations for data collectors -->
<DataCollectionRunSettings>
<DataCollectors>
<DataCollector friendlyName="Code Coverage" uri="datacollector://Microsoft/CodeCoverage/2.0" assemblyQualifiedName="Microsoft.VisualStudio.Coverage.DynamicCoverageDataCollector, Microsoft.VisualStudio.TraceCollector, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<Configuration>
<CodeCoverage>
<ModulePaths>
<Exclude>
<ModulePath>.*CPPUnitTestFramework.*</ModulePath>
</Exclude>
</ModulePaths>
</CodeCoverage>
</Configuration>
</DataCollector>
</DataCollectors>
</DataCollectionRunSettings>
<!-- Adapter Specific sections -->
<!-- MSTest adapter -->
<MSTest>
<MapInconclusiveToFailed>True</MapInconclusiveToFailed>
<CaptureTraceOutput>false</CaptureTraceOutput>
<DeleteDeploymentDirectoryAfterTestRunIsComplete>False</DeleteDeploymentDirectoryAfterTestRunIsComplete>
<DeploymentEnabled>True</DeploymentEnabled>
</MSTest>
</RunSettings>
When using the # modifier you shouldn't escape the backslashes. So use either [DeploymentItem("TestProject\\TestFiles\\test file.rit", "TestData")] or [DeploymentItem(#"TestProject\TestFiles\test file.rit", "TestData")]. The second version is preferable.
From my experience, if a file is added to the project at its root level, then it can be referenced just by [DeploymentItem("file.xyz")] in the test case. So in your case [DeploymentItem(#"TestFiles\test file.rit", "TestData")] should be fine.
You also need to remember to "Enable deployment" in "Solution items" -> Local.testsettings:

Categories

Resources