List of CATVBA InputObjectTypes? - vba

For CATIA V5, the following lines of code prompt the user to select a feature, filtered by type.
Dim InputObjectType(0) As Variant
InputObjectType(0) = "Point"
selection1.SelectElement2(InputObjectType, "Select a point", true)
etc...
I want to filter on Geometrical Sets. "Geometrical Set", "GeometricalSet", and "GeoSet" do not work. Is there a list or table of object type names? The v5automation.chm file does not offer any clues.

Not sure if you're checking SO for answers or not - doesn't look like many others have been able to answer your questions to date
If this works for you please mark it as an answer and gain points for yourself as well as myself - and helping future users
I believe you can find a Geometrical set by searching for "HybridBody"
Note: Both Geometric set and Repetition(Points and Planes) are HybridBody
Change your lines of code to:
InputObjectType(0) = "HybridBody"
selection1.SelectElement2(InputObjectType, "Select a Geo Set", true)
Found a list of types - not sure if it's full or not
Other
Volume
Surface
Cylinder
Sphere
Cone
Plane
Curve
Circle
Line
Point
Axis System

There is a generic elements list:
And you can use other filters using the same name used in VBA and not for user interface.
HybridBody = API
GeometricalSet = UI

Related

CATIA Macro "Any geometry infinite"

I am trying to measure distance between a line and a point using below code.
ptref = Partdocument.Part.CreateReferenceFromObject(pt1) 'creating reference from point
refline = Partdocument.Part.CreateReferenceFromObject(line1) 'creating reference from line
Get measure
TheMeasurable = TheSPAWorkbench.GetMeasurable(refline)
dist1 = TheMeasurable.GetMinimumDistance(ptref)
since line and point are at different plane, I am not getting the required output.
I want to to measure using "Any geometry, infinite option".
Please suggest how I can incorporate that.
That is not supported using the SPAWorkbench/Measurable.
As a workaround, it is not difficult to get the end points of the line and perform the calculation using vector algebra.

ListObjects.Add.QueryTable Source Array String

I will provide some context before I ask my question.
I am attempting to query an SQL Server and create a table within Excel from the data. Because I am not familiar with how to accomplish this in VBA I recorded by using Data -> Get External Data -> From Other Sources -> Microsoft Query. In the dialog box that appears, I chose a .DSN file provided to me by someone else. I then used the Microsoft Query interface to structure the query and import the data onto a worksheet.
The code in the recorded macro looked something like this. I will use generic terms instead of the actual code.
With Sheet2.ListObjects.Add(SourceType:= 0, Source:=Array _
(Array("ODBC;DRIVER=SQL Server;SERVER=ServerName;UID=userid;Trusted_Connection=Yes;APP=Microsoft Windows Operating System;WSID=SomeString"), _
Array("A;DATABASE=DatabaseName")), Destination:=Range ("Sheet2!$A$1")).QueryTable
I know this is not formatted ideally, which is part of my question below.
https://msdn.microsoft.com/en-us/library/bb211863(v=office.12).aspx
From the above article, I know that SourceType:= 0 is an xlSrcExternal, or an external data source. This makes sense to me.
My confusion begins to arise when I get to the Source component of the Add method. From the provided article, "When SourceType = xlSrcExternal, an array of String values specifying a connection to the source, containing the following elements:
•0 - URL to SharePoint site
•1 - ListName
•2 - ViewGUID
So to begin with, what exactly is meant by "an array of String values", as the code from the recorded macro does not appear to correspond to what I thought was an array. I know that normally an array is declared something like this Array("string1", "string2", etc.). Or is the array recorded simply an array of one value? In other words Array("string1"). Does anyone know the purpose of passing an "array of string values" as opposed to just passing a string?
Also does anyone know the nuances of why the recorded macro has this particular formatting/syntax? In other words, why does it appear to have this syntax Array(Array("string1"),_ (new line) Array("string2"))? Why not just Array ("string1")? Does it have something to do with the second line being too long?
I have several more questions related to this topic, but this seemed like a good place to start..
Thank you all for any help given.

How to set a required reasource location as a variable?

I'm currently making a game for an Advanced Higher computing course. After having my previous question answered perfectly and helping me a great bunch. I was wondering if you could share you wisdom upon me once again...
I've currently declared the variables, got the selection process narrowed down. All I'm sturggling to do is for it to recognise it's a variable and not the location itself.
UsedTile = My.Resources.Token(Turn)
CurrentTile = My.Resources.Colour(Turn)
I should also mention that UsedTile and CurrentTile are declared as Image so that it works with the rest of my progam.
Token is an array that swaps between 1 & 2 which is defined by Turn.
Sorry if i'm explaining this baddly, but basically I would want it to look something like
UsedTile = My.Resources.(Colour(Turn))
So that it is interchangable. All of the reasources are there, so for instance it would be a red tile it should show as
UsedTile = My.Resources.ColourRed.png
Thanks, I hope I've made it understandable. I'd happily upload more code if needed :)
-Lewis
It's a little unclear what it is that you are asking, but here are two suggestions that may help you. First, you may want to consider reading the resources once and storing them in some other data structure that makes them more convenient to access when you need them later. For instance, if you created a class like this:
Public Class ColourResources
Public Property TurnImages As Image(2)
End Class
Then you could create an array of them and fill them like this:
Dim colors(2) As ColourResources
colors(0).TurnImages(0) = My.Resources.ColourRed
colors(0).TurnImages(1) = My.Resources.ColourRedUsed
colors(1).TurnImages(0) = My.Resources.ColourBlack
colors(1).TurnImages(1) = My.Resources.ColourBlackUsed
Then when you need a particular image, you could just access in some way similar to this:
Dim tile As Image = colors(currentColor).TurnImages(currentTurn)
If your colors and turns are kept track of with some data type other than an Integer, you could use dictionaries instead of arrays.
My second suggestion is that it is possible to get the resource by string name rather than via resource-designer-auto-generated property. For instance, instead of this:
UsedTile = My.Resources.ColourRed
You could also access the same image like this:
UsedTile = DirectCast(My.Resources.ResourceManager.GetObject("ColourRed"), Image)
Depending on your needs, that may be useful to you.

Changing the color of a leader in AutoCad

I'm currently working on converting a VBA AutoCAD-application over to VB.NET, and the current command I'm working on is creating a simple leader with code like this:
Set leaderObj = ThisDrawing.ModelSpace.AddLeader(points, blockRefObj, leaderType)
leaderObj.ArrowheadType = acArrowDotSmall
leaderObj.ArrowheadSize = 2.5 * varDimscale
leaderObj.DimensionLineColor = acWhite
I've been able to create the Leader-line in .NET using
Dim l = New Leader()
For Each point In jig.LeaderPoints
l.AppendVertex(point)
Next
l.Dimldrblk = arrId
The arrId I got from using the function found here, but I've been unable to figure out how to set the color of the leader to white (it shows up as red by default), and also how to set the size of the arrowhead. If anyone could help me out with this I would be most grateful.
Ok, after a lot of trial and error, I figured out that the solution was rather simple. I didn't have to override any dimension styles (which I honestly don't even know what is, I had a short beginners course in AutoCAD before getting handed this project), I simply had to set an obscure property on the Leader-object. For future references, and for anyone else trying to do the same, here's the properties I ended up using:
leader.Dimclrd
The color of the leader-line. Stands for something like "dimension line color".
leader.Dimasz
The scale of the leader-head.
As type BlockReference, it should have a color property and the property should be an Autodesk.Autocad.Colors.Color or an Integer. Also the reason you are getting the object for read is, in your transaction you are opening the database with
OpenMode.ForRead
And that is correct. But to edit the object in the database, you must retrieve the object like below
var obj = Thetransaction.GetObject(theobjectid,OpenMode.ForWrite) as BlockReferance;
This is done inside of the
using(var trans = TransactionManager.StartTransaction()){}
I'm doing this on a cell, so check the camel case and syntax because I write in c#, but it should be pretty close.
You may want to see if there is a scale property, as to change the size.
Hopefully this will move you in the right direction.
Let me know if you have any problems. :)

Semantic mediawiki - Set propery to range of values

I'm trying to set a specific property to a non exact value, for example say that I want to define the height of a pine tree to usually between 3-80 m (according to wikipedia). Then I would like to set something like [[Has height::3-80]] (of course this doesn't work) and defining the unit to meters with "custom units". Then I would like to be able to query for example "trees that can reach the height of 70 meters" and the pine tree would be included. I've been searching and trying different angles for hours now and I can't figure it out. Tried with #set_recurring_event but that seems to be only for dates/time. Also understood how to set multiple values for a property with #arraymap but this doesn't seem to help me here. Really would appreciate help with this (it's probably very easy and right in front of me) Thx! COG
There's no such things. But you able to create template, with parameters you want. The you just use code kinda {{range|min|max|units}}. For example your range of heights looks like {{range|3|80|m}}.