Author Topic: VBA In Microstation  (Read 6802 times)

0 Members and 2 Guests are viewing this topic.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
VBA In Microstation
« on: January 13, 2006, 10:35:48 AM »
Ok .. I have come to a roadblock ...  As some of you are aware (and now the rest of you) .. I am working in Microstation on a contract project. .. I have absolutely NO customization and am working on building some tools. Anyway, I have the need to take multiple cells and programmatically put them in a single cell.

What I have done is create each of my CellElements and placed them in an element array .. i.e.

Set myElements(X) = myCellElement

When I am done, I create a new element at the same spot and at the same scale as the previous one. i.e.I use CreateCellElement2 to make my base cells and then use CreateCellElement1 to make the master cell using the array of elements in myElements.

I am fine up through this point, except the tags attached to the cell created by CreateCellElement2 are not transferred into the element created by CreateCellElement1 ... so in my mind, I thought .. why not simply grab the tags from my base cell and attach them to the master cell, unforunately, it is not that easy to do ... plus when I attempt to use the RemoveElement method on the base cell (to remove it from the design) I get an error that I cannot do that on a complex CellElement.

Any ideas? If I get some more time, I'll extract some of the code and place it here.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

deegeecees

  • Guest
Re: VBA In Microstation
« Reply #1 on: January 13, 2006, 02:28:05 PM »
I've been poking my nose in the VBA stuff we recieved from a client, and I'm not really sure whats going on with it but the person who wrote it uses alot of SendCommand to set variables and such. There is also a function to add Tag Data to a cell (in this case a Titleblock).

I'll post something in a little bit.

Arizona

  • Guest
Re: VBA In Microstation
« Reply #2 on: January 16, 2006, 06:56:05 AM »
This sounds very close to a bug I found in Microstation. I was doing a simple change and replace for a title block and swapping out the attributes/tags. When I could not get the tags to accept the new information. I sent all of it to Bentley and they admitted this was a bug. This was in V8. If I can find the thread I'll post it.

deegeecees

  • Guest
Re: VBA In Microstation
« Reply #3 on: January 16, 2006, 10:37:39 AM »
Still in need of ideas Craig?

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: VBA In Microstation
« Reply #4 on: January 16, 2006, 11:01:56 AM »
uh ... I think I might have found the problem .. but I was so tired after my long weekend, I havn't messed with it ...

I think the issue is with the tags not being considered part of the cell even though they are defined within the cell, thus the RemoveElement methid does not work and the addition of cell tags do not work programmatically when they are attaced to another element ... so I figure I must grab the tags, enumerate them into a new tagset, then apply that tagset to my new cell ... seems like a long way around the bucket to get to the handle .. but I think it might work ... oh .. and I solved the issue with the deletion of the old cell element ... although I had to enumerate every cell within the design file to do so ... you would think they would have a delete method for the elements .. but alas there is none ...
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: VBA In Microstation
« Reply #5 on: January 18, 2006, 09:46:09 AM »
Ah .. finally some light at the end of the tunnel .....

For those interested .. here is what I did ...
Code: [Select]

Set myCell1 = ActiveModelReference.CreateCellElement2(cellName1, OriginPoint, CellScale, False, ElementRotation)
ActiveModelReference.SelectElement myCell1, True
Set myCell2 = ActiveModelReference.CreateCellElement2(cellName2, OriginPoint, CellScale, False, ElementRotation)
ActiveModelReference.SelectElement myCell2, True
CadInputQueue.SendKeyin "group selection "

Only problem is that the tags are now a part of the master cell for some reason .. I am still working on it, but for now, it works ....
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

Arizona

  • Guest
Re: VBA In Microstation
« Reply #6 on: January 19, 2006, 06:30:55 AM »
Way to go Keith! I can appreciate what you went through to get there.
So, How many times did you feel like you were beating your head up against a wall? :-)

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: VBA In Microstation
« Reply #7 on: January 19, 2006, 08:04:58 AM »
a bunch .. I still feel like I am doing it .. last night I went to tackle the tags issue and ... well lets just say I am going to have to rethink the whole problem ... again ... I will likely have to (although I don't relish the idea), take the tags existing in my main cell, copy them to an array, create a new tagset using the existing set, and move all of the data from the old tagset to the new tag set ... but get this ... the origin and width of the tag is read only ... what the hell were they thinking?
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

Arizona

  • Guest
Re: VBA In Microstation
« Reply #8 on: January 24, 2006, 02:19:42 PM »
a bunch .. I still feel like I am doing it .. last night I went to tackle the tags issue and ... well lets just say I am going to have to rethink the whole problem ... again ... I will likely have to (although I don't relish the idea), take the tags existing in my main cell, copy them to an array, create a new tagset using the existing set, and move all of the data from the old tagset to the new tag set ... but get this ... the origin and width of the tag is read only ...

I would be interested in the solution you come up with for dealing with the tags. I have a similar problem where I could not get the tags to accept the values I was trying to pass. The values were valid and I could capture them before passing them, but the minute I tried to pass them to the tags the whole thing bombed.

what the hell were they thinking?
Oh, Were they thinking?

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: VBA In Microstation
« Reply #9 on: January 24, 2006, 02:34:26 PM »
I am still working on it ... no solution as of yet ...
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie