Author Topic: civil 3d 2010 and vb.net  (Read 12411 times)

0 Members and 1 Guest are viewing this topic.

neyton

  • Newt
  • Posts: 68
civil 3d 2010 and vb.net
« on: August 03, 2009, 06:45:53 PM »
I am writing a program for civil 3d (pipenetwork), but can not set the value of a partdatafield I've created:

Code: [Select]
Imports Autodesk.Civil.PipeNetwork.DatabaseServices
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Microsoft.VisualBasic
Imports Autodesk.AutoCAD.EditorInput
Imports Autodesk.AutoCAD.Runtime

Public Module c3d2010
    <CommandMethod("test")> _
    Public Sub test()
        Dim doc As Document = Application.DocumentManager.MdiActiveDocument
        Dim ed As Editor = doc.Editor
        Dim ts As Transaction = doc.Database.TransactionManager.StartTransaction()

        Dim pipeid As ObjectId = ed.GetEntity( _
           New PromptEntityOptions(vbNewLine & "Select Pipe:")) _
          .ObjectId

        Dim fieldname As String = ed.GetString( _
           New PromptStringOptions(vbNewLine & "tag:")) _
           .StringResult

        Dim value As Double = ed.GetDouble( _
           New PromptDoubleOptions(vbNewLine & "value:")) _
           .Value

        Dim tubo As Pipe = ts.GetObject(pipeid, _
            Autodesk.AutoCAD.DatabaseServices.OpenMode.ForWrite)

        Dim pf As PartDataField = tubo.PartData.GetDataFieldBy(fieldname)
        Dim oldval As Double = pf.Value

        pf.Value = value

        ts.Commit()

        ed.WriteMessage(vbNewLine & "New=" & pf.Value & _
                        vbNewLine & "Old=" & oldval & _
                        vbNewLine & "real value=" & _
                        tubo.PartData.GetDataFieldBy(fieldname).Value)
    End Sub

End Module

the test it should be, for example:
Command: test
Select pipe:
tag: coef
Value: 3
-------
New = 3
Old = 10
real value = 3

but "real value" is equal to 10 (old value)
why not work?

-----------------------
the partdatafield was created as (in AeccPartParamCfg.xml):
<AeccDfParameter name="coef" desc="coeficiente" context="coef_" index="0" datatype="Float" usage="Double_general" unit="" visible="True" internal="True"/>

and (in AeccPartParamCfg.xml)
<AeccPartDomainCfg domain="Pipe_Domain">
  <AeccReqParam context="SweptShape"/>
  <AeccPartTypeCfg type="Pipe" desc="Pipe">
 <AeccOptParam context="coef_"/>
...

Visit my website: http://tbn2.blogspot.com

neyton

  • Newt
  • Posts: 68
Re: civil 3d 2010 and vb.net
« Reply #1 on: August 05, 2009, 07:41:50 AM »
up!

so? nothing?
Visit my website: http://tbn2.blogspot.com

neyton

  • Newt
  • Posts: 68
Re: civil 3d 2010 and vb.net
« Reply #2 on: August 13, 2009, 10:07:31 AM »
autodesk, are you here???
Visit my website: http://tbn2.blogspot.com

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8659
  • AKA Daniel
Re: civil 3d 2010 and vb.net
« Reply #3 on: August 13, 2009, 10:13:28 AM »
I don't think many from Autodesk party here. I'd love to help but, I've never used C3D. I think sinc is our resident C3D master, maybe he'll pop in.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: civil 3d 2010 and vb.net
« Reply #4 on: August 13, 2009, 10:24:34 AM »
autodesk, are you here???

No, autodesk is not here ... you can find them here

Now on to your particular problem ...

You have defined a variable pf that holds the value of the datafield ... this variable may not automatically update to the part it came from .. you might have to manually write it back to the object ...


I don't have C3d so I can't test it .. but maybe you should do something like:

Code: [Select]
tubo.PartData.GetDataFieldBy(fieldname).Value = value

Incidently, you might want to tweak your variable names so they aren't the same as properties of objects in your code .. it can get confusing to read value = value ..
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

sinc

  • Guest
Re: civil 3d 2010 and vb.net
« Reply #5 on: August 13, 2009, 10:49:51 AM »
I think you scared off half the people when you said "VB", and the other half when you started talking about working with Parts via the API...   :-D

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: civil 3d 2010 and vb.net
« Reply #6 on: August 13, 2009, 10:58:47 AM »
awww... come on now sinc ... VB isn't *all* bad ...

and API programming is pretty neat stuff
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

sinc

  • Guest
Re: civil 3d 2010 and vb.net
« Reply #7 on: August 13, 2009, 11:06:36 AM »
and API programming is pretty neat stuff

You've obviously never used the Civil 3D API.   :lol:

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: civil 3d 2010 and vb.net
« Reply #8 on: August 13, 2009, 11:10:03 AM »
lol .. its that obvious is it ...

No, I don't have Civil 3D, and as a result, I don't use the C3D API .. but I have used API's (published and unpublished) from programs that are likely as scary ... once understood, there isn't a problem .. it can actually be quite fun.
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

sinc

  • Guest
Re: civil 3d 2010 and vb.net
« Reply #9 on: August 13, 2009, 11:35:01 AM »
Yeah, I agree...  I must enjoy doing it, because I keep doing it.

The Civil 3D API is quite a mess.  They started out creating a COM API, then recently decided to focus on the managed API and ignore the COM API.  So now we have some things that are available only via the COM API, and some that are available only via the managed API, and we basically have to use a mish-mash of both.  And many things are not available at all via the API, which is a constant source of frustration, as entire tasks are prevented because one part is not available via the API.  Plus, the whole API is very low-level, anyway - hardly more than a wrapper around some core functions, with few (if any) events, etc. - and not really the sort of thing I've grown to expect from a true Framework.

But with all its problems, it's still a pretty powerful API.  It's much better than what Bentley has for PowerCivil, or what Carlson has for Carlson Civil.   :-)

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: civil 3d 2010 and vb.net
« Reply #10 on: August 13, 2009, 11:55:36 AM »
So, have you verified whether or not my suggestion will resolve the OP problem?
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

sinc

  • Guest
Re: civil 3d 2010 and vb.net
« Reply #11 on: August 13, 2009, 12:38:19 PM »
The API is full of gotchas and quirks and incomplete access.  I haven't dug into Pipe Networks or Parts yet, so I'm not familiar with might be lurking there.  It's something I'll probably be getting into soon, but I haven't tried messing with that area yet.

Spike Wilbury

  • Guest
Re: civil 3d 2010 and vb.net
« Reply #12 on: August 13, 2009, 01:09:16 PM »
no idea if the MEP API it is related, but for what i have seen and done with this api, to modify a pipe size, you have to use DataQuery and then the Domain and add your size parameters, then query the part GUID, then get the DataRecordCollection, then use a DataRecord and then the PartManager.ModifyPartViaRecord and ROCK AND ROLL

pretty straight forward (aha.....  :lmao: )

neyton

  • Newt
  • Posts: 68
Re: civil 3d 2010 and vb.net
« Reply #13 on: August 14, 2009, 04:01:18 PM »
Yes, I try:
Code: [Select]
...
tubo.PartData.GetDataFieldBy(fieldname).Value = val
...
and not work too


may be.... is it is missing some "openmode.forwrite" in the "transaction manager"?

I like Visual Basic, and with Visual Studio, you can say that is equivalent to C#

----

no "PartManager.ModifyPartViaRecord" in civil 3d api


( translate with google, hehehe )
Visit my website: http://tbn2.blogspot.com

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: civil 3d 2010 and vb.net
« Reply #14 on: August 14, 2009, 04:10:24 PM »
I don't know the answer
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