PDA

View Full Version : How can i get the data of active piperun



shss
07-12-2011, 07:23 PM
Hi, there is the code:

Dim DataSource As LMADataSource
Set DataSource = New LMADataSource

Dim objFilter As LMAFilter
Dim criterion As LMACriterion
Set criterion = New LMACriterion
Set objFilter = New LMAFilter

Set objPl = New Placement
Set ds = objPl.PIDDataSource
pid_id = ds.PIDMgr.Drawing.ID

criterion.Conjunctive = True
criterion.SourceAttributeName = "ItemStatus"
criterion.ValueAttribute = 1
criterion.Operator = " = "
objFilter.itemType = "Piperun"
objFilter.Criteria.Add criterion

Set criterion = New LMACriterion
criterion.Conjunctive = True
criterion.SourceAttributeName = "Representation.Drawing.SP_ID"
criterion.ValueAttribute = pid_id
criterion.Operator = " = "
objFilter.Criteria.Add criterion

Dim piperun As LMPipeRun
Dim piperuns As LMPipeRuns
Set piperuns = New LMPipeRuns
piperuns.Collect DataSource, Filter:=objFilter

Debug.Print "Total Piperuns found: " & piperuns.Count
DataSource.BeginTransaction

For Each piperun In piperuns
List1.AddItem (piperun.Attributes("ItemTag").Value)
Next

DataSource.CommitTransaction
ds.CommitTransaction
Set DataSource = Nothing
Set objFilter = Nothing
Set criterion = Nothing
Set piperun = Nothing
Set piperuns = Nothing
But this code select all piperuns in the drawing. Which criterion helps me select an active line and gets data?
or maybe exist the another way to make it?
Thx.

tim
07-12-2011, 07:57 PM
Filter/criteria is applied to database condition. You cannot get active pipe run by any filter.

If you are still developing foreign calculation ActiveX dll, you don't need to apply filter, information of selected items is coming as parameter in ILMForeignCalc_DoCalculate.

shss
07-12-2011, 08:30 PM
thx, tim.
i understand how use ILMForeignCalc_DoCalculate, but for one selected item
for example, show ItemTag:
Debug.Print Items.Nth(1).Attributes("ItemTag").Value

But if we have multiselection, how we get data? maybe use some array or LMAPipeRuns?

tim
07-12-2011, 08:51 PM
????
Simply loop through items.

For i=1 to Items.Count
Debug.Print Items.Nth(i).Attributes("ItemTag").Value
Next

shss
07-12-2011, 09:14 PM
wow, so easy.
well, tim, i have another question: could u tell me how handle actions (for example, we choose piperun and start drawing it, i wonna handle a right click button, when we finish draw the line. Or another example, when we connect one line to another)?

tim
07-12-2011, 09:29 PM
Such kind of application to catch user's action is impossible by end user development.
By SmartSketch API, we can catch mouse click event or similar one. But we can not judge when placement complete without modifying core basic command.
Ask Intergraph.

shss
07-12-2011, 09:37 PM
ask alredy, now waiting an answer.
well thank u tim, u very help me.