How to execute a native Inventor Command? - add-in

First post!!
The code (snippet listed below) compiles, builds, runs without any errors. MessageBox.Show("New Sketch") runs without an issue, but cd.Execute() does not appear to fire.
When I do a quick watch on 'cd.Execute()' the information displayed reflects that the correct command is being accessed, but nothing happens on screen.
As this is my very first addin to try and write, I'm pretty green behind the ears. I've done some extensive Googling, but apparently I'm googling the wrong terms.
Any assistance is appreciated!
Code Snippet:
Private Sub m_Sketch_OnNewSketch(DocumentObject As _Document,
Sketch As Sketch,
BeforeOrAfter As EventTimingEnum,
Context As NameValueMap,
ByRef HandlingCode As HandlingCodeEnum) _
Handles m_SketchEvent.OnNewSketch
Select Case BeforeOrAfter
Case EventTimingEnum.kBefore
Case EventTimingEnum.kAfter
Dim cd As ControlDefinition =
m_inventorApplication.CommandManager. _
ControlDefinitions.Item("SketchSliceGraphicsCmd")
cd.Execute()
MessageBox.Show("New Sketch")
Case EventTimingEnum.kAbort
End Select

Related

Ctypes mozilla unknown error

In a mozille extension I run:
SecSess.Logger.info("ctypes test");
Components.utils.import("resource://gre/modules/ctypes.jsm");
SecSess.Logger.info("1");
this.lib = ctypes.open("libcrypto.so");
SecSess.Logger.info("2");
var a = new Uint8Array(1<<10);
SecSess.Logger.info("3");
var ptr = new ctypes.uint8_t.ptr(a.buffer);
SecSess.Logger.info("4");
Why this ugly logging after each step you might ask? Well this code fails without showing me an error. (or at least I can't find the error message)
This is printed:
ctypes test
1
2
3
So the 5th log message is never printed which means the following statement never completes:
var ptr = new ctypes.uint8_t.ptr(a.buffer);
This is a simplified version of some old code I have to work with and which I also found online as being valid. However it doesn't work. This add-on wasn't developped using the new SDK with jpm. Quite frankly I don't know how and when it was developped but I need to run some tests on it. It comes with a few source files ordered in a components and a modules directory and a chrome.manifest and install.rdf in the root. I copied these files to the extension directory of Mozilla in order for it to work. The extension executes but there seems to be a problem with ctypes. Aren't ctypes fully supported anymore or are these old style add-on no longer valid for the modern Firefox?
Regards,
Roel
I think they landed a a patch to disallow making a pointer from buffers. I'll double check.
Edit:
Ah per this: https://developer.mozilla.org/en-US/docs/Mozilla/js-ctypes/Using_js-ctypes/Working_with_ArrayBuffers, you don't have to wrap it with a ctypes.uint8_t.ptr just pass it like a.buffer to wherever you need it. :)

XQuery query to delete marked documents sometimes runs indefinitely

I have an XQuery query intended to wipe test documents from the database before each test that is run. Essentially it looks for a certain element to be present as a top level element in a document (called 'forTestOnly') and if it finds it it deletes the document. This query is run before each test in order to ensure the tests don't interfere with one another (we have about 200 tests using this). The exact XQuery is as such:
xquery version "1.0-ml";
import module namespace dls = "http://marklogic.com/xdmp/dls" at "/MarkLogic/dls.xqy";
let $deleteNonManagedDocs := for $testDoc in /*[forTestOnly]
let $testDocUri := fn:base-uri($testDoc)
where fn:not(dls:document-is-managed($testDocUri))
return xdmp:document-delete($testDocUri)
let $deleteManagedDocs := for $testDoc in cts:search(/*[forTestOnly], dls:documents-query())
let $testDocUri := fn:base-uri($testDoc)
return dls:document-delete($testDocUri, fn:false(), fn:false())
return ($deleteManagedDocs, $deleteNonManagedDocs)
While it seems to work fine most of the time, it recently has begun to sporadically spiral out of control. At some point during the test execution it begins to run for a near indefinite amount of time (I usually stop it after 600-700 seconds), most of the time it takes less than a second though. The database used for testing is not large (it has a few basic seed documents but nothing compared to a production database), and typically each test only creates a handful of documents with the 'forTestOnly' (if not less).
The query seems simple enough, and although running it 200 times in relatively quick succession would understandably put a strain on the database I can't imagine it would cause this kind of lagging (the tests are Grails integration tests and the entire execution takes a little over two minutes). Any ideas why the long run time?
As a side note I have verified that when the tests stall it is indeed after the XQuery has begun to run and not before in some sort of test wiring/execution.
Any help is greatly appreciated.
The query might look simple, but it isn't necessarily simple to evaluate. Those dls function calls could be doing anything, so it's tricky to estimate the complexity. The use of DLS also means that we don't know how much version history has to be deleted to delete each document.
One possibility is that you've discovered a bug. It might already be fixed, which is a good reason why you should always report the full version of the software you're using. The answer may be as simple as upgrading to pick up the fix.
Another possibility is that your test suite ends up running all of this work in a single high-level evaluation, so everything's in memory until the end. That could use enough memory to drive the server into swap. That would explain the recent "spiral out of control" behavior. Check the OS and see what it says.
Next, set the group file-log-level=Debug and check ErrorLog.txt while one of these slow events is happening. If you see XDMP-DEADLOCK messages, you may have a problem where two or more copies of this delete query are running at the same time. MarkLogic has automatic deadlock detection and resolution, but it's faster to avoid the deadlock in the first place.
Some logging might also help determine where the time is spent. Something like:
let $deleteNonManagedDocs := for $testDoc in /*[forTestOnly]
let $testDocUri := fn:base-uri($testDoc)
where fn:not(dls:document-is-managed($testDocUri))
return (
xdmp:log(text { 'unmanaged', $testDocUri }),
xdmp:document-delete($testDocUri))
let $deleteManagedDocs := for $testDoc in cts:search(/*[forTestOnly], dls:documents-query())
let $testDocUri := fn:base-uri($testDoc)
let $_ := xdmp:log(text { 'managed', $testDocUri })
return dls:document-delete($testDocUri, fn:false(), fn:false())
return ()
Finally you should also be able to simplify the query a bit. Since you're deleting everything, you can just ignore DLS.
xdmp:document-delete(
cts:uris(
(), (),
cts:element-query(xs:QName('forTestOnly'), cts:and-query(())))
This would be even simpler and more efficient if you set a collection on every test document: xdmp:collection-delete('test-docs').

Standard print button is inoperative in custom Report

My customer has reported a problem that standard ''print'' button in Z-report which a developer wrote before is not working.
How can I enable the button?
MODULE user_command_0100 INPUT.
DATA: GS_STATUS TYPE SLIS_STATUS,
XS_STATUS LIKE GS_STATUS.
CASE sy-ucomm.
WHEN 'BACK' OR '%EX' OR 'RW'.
LEAVE TO SCREEN 0.
WHEN '&RNT'.
ENDCASE.
ENDMODULE.
Then button needs a usercommand assigned, which is then processed in pai. usually with a general form called get_ucomm (many developers call it similar). You also can issue /h in transaction field and then press the print-button. /h will trigger the debugger and You can inspect the report step by step.
That's all I can say without seeing the code. Hope this will help.
Which user command do you define in your GUI status?
If you have a standard list (what I expect when you write about a z-report), then you should define the command PRI to print the list:
If you define a screen (using the screen painter) or an ALV-Grid... then this solution will not help you.
If you don't know, what a GUI status is: Scan your source code for the command
SET PF-STATUS 'XXXX'.
Then double click on 'XXXX' and you should be directed to the status definition. There may by multiple status (and status with generic names).
I've seen your code and for the &RNT option there's no code to execute, so if the user wants to print the button will do nothing.
MODULE user_command_0100 INPUT.
DATA: GS_STATUS TYPE SLIS_STATUS,
XS_STATUS LIKE GS_STATUS.
CASE sy-ucomm.
WHEN 'BACK' OR '%EX' OR 'RW'.
LEAVE TO SCREEN 0.
WHEN '&RNT'.
" There's no code
ENDCASE.
ENDMODULE.
I've used the 'STANDARD' GUI Status from the function group 'KKBL' and '&RNT' is the code of the print button and that's why I think that is the print button you are refering in your program.
Can you post the GUI Status you are using please?

Running F# xUnit Fact from TestDriven.NET reporting "It looks like you're trying to execute an xUnit.net unit test."

I am trying to run xUnit tests (from an F# module, if it makes any difference) using TestDriven.NET, but whatever I do I get this error:
It looks like you're trying to execute an xUnit.net unit test.
For xUnit 1.5 or above (recommended):
Please ensure that the directory containing your 'xunit.dll' reference also contains xUnit's
test runner files ('xunit.dll.tdnet', 'xunit.runner.tdnet.dll' etc.)
For earlier versions:
You need to install support for TestDriven.Net using xUnit's 'xunit.installer.exe' application.
You can find xUnit.net downloads and support here:
http://www.codeplex.com/xunit
I tried following the suggestions, i.e. I copied the files
xunit.dll.tdnet
xunit.extensions.dll
xunit.gui.clr4.exe
xunit.runner.tdnet.dll
xunit.runner.utility.dll
xunit.runner.utility.xml
xunit.xml
to the folder with xunit.dll and I ran xunit.installer.exe. How can I get it to work?
I just figured out that I forgot to make the test a function in F# (so it was just a value). The error message can't be more misleading though!
You have two problems:
your Fact is broken:-
If you hover over the
please work
bit, you'll see something like: unit -> int
For a Fact to be picked up by an xUnit runner, it needs to yield `unit (void).
Hence, one key thing to get right first is to not return anything. In other words, replace your 123 with () (or an Assertion).
You can guard against this by putting a :unit stipulation on the test:-
[<Fact>]
let ``please work`` () : unit = 123
This will force a compilation error.
TestDriven.NET is reporting it cannot find the xunit.tdnet modules
It's critical to get step 1 right first. Then retry and the problem should be gone
If it remains...
Either try the VS-based runner which should work as long as it's installed and xunit.dll is getting to your output dir or look at the docs for your version of TD.NET for detailed troubleshooting notes (exec summary is if the .tdnet file was in your out dir or you undo and redo the xunit.installer from the folder containing the packages it should just work, esp if you are on latest)

VB6, ActiveReports, and Ricoh printers: Rotating the Page?

I have a BEAST of a program written in VB6. It uses ActiveReports to generate letters.
The reports are processed in a loop; with verbage-building loops and (a whole lotta) nested 'if' and 'case' statements. Fugly!
The reports are sent to the printer like such:
Function PrintIt(ltrobj as Object)
Set ltrobj = MyARdocument '(.Dsr file)
ltrobj.txtfield1 = strVerbage 'This string was populated somewhere else
ltrobj.Printer.DisplayProgressDialog = False
ltrobj.PrintReport False
End Function
Now here's the weird part: The pages physically come out of the printer rotated 90 degrees each iteration of the loop. What's even weirder -- this only happens for my VB6 application -- other Word documents, reports, batch jobs, whatever come out normal.
So the first page comes out like normal, the header first (pointing North). The second page comes out sideways (header pointing West). The third comes out of the printer like the first, the fourth comes out like the second, and on and on...
The printer: A Ricoh Aficio MP5000
I cannot find a setting on the printer, or a property in ActiveReports that controls this.
Any ideas, help, or a general direction would be greatly appreciated!
Thanks,
Jason
There is no "rotation" setting in ActiveReports. The closest things that might impact this would be the page size and orientation, but at worst I would expect them to flip back and forth not actually rotate the page. I would try to do a few things:
Trace the printer & page settings related to orientation and page size as report prints.
Try printing to another printer to see if it happens on all printers or just this one.
Preview the reports on screen and see if they're rotated in the preview or not (or export them to PDF with report.Export(...) ad see if they're rotated there).
To trace page settings you should do it in a couple places. One on the printer, and another on each page (or Canvas) in the report. There is also the ActiveReport.PrintWidth (the width of the report, not the pages) that may also be relevant. So just before printing each report try tracing out the following values:
report.PrintWidth
' the default settings for the report
report.PageSettings.TopMargin
report.PageSettings.RightMargin
report.PageSettings.BottomMargin
report.PageSettings.LeftMargin
' actual printer's current settings:
report.Printer.PaperSize
report.Printer.PaperHeight
report.Printer.PaperWidth
report.Printer.Orientation
' settings for a specific page:
for each page in report.Pages:
report.Pages(...).Width
report.Pages(...).Height
report.Pages(...).Orientation
BTW: ActiveReports COM Help is here.
If the preview/PDF test seems okay then I'd focus on the printer itself. Same for the print to another printer obviously. Otherwise, focus on ActiveReports settings.
Hope this helps
Scott Willeke
GrapeCity

Resources