Create point matrix or convert text string to PointOrMatrix

Create point matrix or convert text string to PointOrMatrix

tbrausen
Participant Participant
657 Views
5 Replies
Message 1 of 6

Create point matrix or convert text string to PointOrMatrix

tbrausen
Participant
Participant

Hi, I get the following error when I run the attached Position_Point rule. Is there instruction of how to create the position matrix it's looking for or convert a string to it?

 

Error on line 37 in rule: Add Pipe, in document: Spreader Bar -3600.iam

Unable to cast object of type 'System.String' to type 'Autodesk.iLogic.Types.PointOrMatrix'.

 

Is there a wild card that could be used for the occName, say Pipe:"?" that would get it to take the next number as Inventor does when manually placing the same part into an assembly? As it is I can only place one of that content center part in the assembly.

Thank you for looking at this,

Tom

0 Likes
Accepted solutions (1)
658 Views
5 Replies
Replies (5)
Message 2 of 6

A.Acheson
Mentor
Mentor

Hi @tbrausen 

Just putting this in the editor to more easily read the code.

 

Components.ContentCenterLanguage = "en-US"
oPartDoc = ThisDoc.Document
Dim oPick1 As Object = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAllCircularEntities, "Pick insert circle 1")
Select Case oPick1.GeometryType
Case CurveTypeEnum.kCircleCurve
	MessageBox.Show("Message2", "Title")
	Dim circ As Inventor.Circle
	circ = oPick1.Geometry
	GetCenterPoint = circ.Center
Case Else
	MessageBox.Show("Message5", "Title")
	GetCenterPoint = Nothing
End Select
oCenter = GetCenterPoint
If Not oCenter Is Nothing Then 
	MessageBox.Show("Center: " & oCenter.X.ToString() & ", " & oCenter.Y.ToString() & ", " & oCenter.Z.ToString())
End If 
Dim oPick2 As Object = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAllCircularEntities, "Pick insert circle 2")
'Dim pick2 As Object = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFacePlanarFilter, "Pick face 2")
Dim entityOneInferredType As InferredTypeEnum = InferredTypeEnum.kNoInference
Dim entityTwoInferredType As InferredTypeEnum = InferredTypeEnum.kNoInference
Dim context As NameValueMap = ThisApplication.TransientObjects.CreateNameValueMap()
Dim distance As Double = ThisApplication.MeasureTools.GetMinimumDistance(
    oPick1,
    oPick2,
    entityOneInferredType,
    entityTwoInferredType,
    context)
Logger.Debug(distance)
For i As Integer = 1 To context.Count
	Dim key = context.Name(i)
    Dim value = context.Value(key)
    Logger.Debug("{0}: {1}", key, value)
Next

Components.AddContentCenterPart("Pipe:1", "Steel Shapes:Round", "ISTD-PIPE-304SS WIP", 
                                                 {"LENGTH_ROUNDED_DN", Floor(Round(distance / 2.54, 4) / .0625) * .0625, "SIZE [Custom]", "1/8""", "TYPE [Custom]", "SCH10" },
                                                 position := oCenter.X.ToString() & ", " & oCenter.Y.ToString() & ", " & oCenter.Z.ToString(), grounded := False,
                                                 visible := True, appearance := Nothing)

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 3 of 6

A.Acheson
Mentor
Mentor

Can you use the capture tool to capture the code of the parts in the assembly? This will give you a sample in which to edit or follow along. 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 4 of 6

tbrausen
Participant
Participant

Hi Mr Achesan,

I'm not sure what you are asking, is there an inventor code capture tool for component data withing the rule editor?

Regards,

Tom

 

 

0 Likes
Message 5 of 6

A.Acheson
Mentor
Mentor
Accepted solution

Yes it uses the ilogic API. Open the ilogic editor and in the browser select the occurence and right click the occurrence and select add.

 

You should get this code automatically. You can then study the syntax you need. Alternatively refer to the Ilogic API help page here for notes on how to fill the syntax.

Components.AddContentCenterPart("Pipe:1",......)

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 6 of 6

tbrausen
Participant
Participant

Thank you, that will be very useful.

0 Likes