Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations KootK on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Etabs Api-Python cEdit class

Status
Not open for further replies.

Raqueeb

Structural
Jun 25, 2013
10
Hello Everyone:
In the auto generated python file in the comtypes folder connected to Etabs.dll there are various classes like EditFrame, EditPoint etc.. I am trying to write a code for EditPoint.ChangeCoordinates and EditFrame.DivideAtDistance but i am not able to execute it. I am getting a return value of -99 instead of 0. And there is no document on these classes in .chm file. Can any one please give a sample of an executable code..
 
Replies continue below

Recommended for you

Hi Raqueeb

Sorry for not getting back sooner, just had a look and doesn't look like there is anything under EditPoint or EditGeneral. Let me have a better look tomorrow morning and see if I can come up with something. I think the SapModel.EditGeneral.Move() may work but will need a selected member. Are you selecting the point through the interface or are you working in the background just relying on knowing a Point Unuique number. Likewise, a user function could be written for Divide at distance. I wrote this one a few years back, think it works for columns

Python:
def subdivide_frame_insert_yloc(SapModel,frame_name,insert_y):
    """
    params frame_name,insert_y
    return None
    """
    (frame_pt0,frame_pt1,ret)=SapModel.FrameObj.GetPoints(frame_name);
    (x0,y0,z0,ret)=SapModel.PointObj.GetCoordCartesian(frame_pt0);
    (x1,y1,z1,ret)=SapModel.PointObj.GetCoordCartesian(frame_pt1);
    frame_ln=((x1-x0)**2+(y1-y0)**2+(z1-z0)**2)**0.5;
    insert_rat=(insert_y-y0)/(y1-y0);
    if(insert_rat>=1):
        print('Insert point outside member');
        return None;
    x2=round(insert_rat*(x1-x0)+x0,1);
    y2=round(insert_rat*(y1-y0)+y0,1);
    z2=round(insert_rat*(z1-z0)+z0,1);
    frame_section=SapModel.FrameObj.GetSection(frame_name)[0];
    frame_grps=SapModel.FrameObj.GetGroupAssign(frame_name);
    frame_mods=SapModel.FrameObj.GetModifiers(frame_name);
    frame_local=SapModel.FrameObj.GetLocalAxes(frame_name);
    SapModel.FrameObj.Delete(frame_name);
    new_point=SapModel.PointObj.AddCartesian(x2,y2,z2);
    new_frame_1=SapModel.FrameObj.AddByPoint(frame_pt0,new_point[0]);
    SapModel.FrameObj.SetSection(new_frame_1[0],frame_section);
    for i in range(len(frame_grps[1])):
        if(frame_grps[1][i]!='All'):
            SapModel.FrameObj.SetGroupAssign(new_frame_1[0],frame_grps[1][i]);
    SapModel.FrameObj.SetModifiers(new_frame_1[0],frame_mods[0]);
    SapModel.FrameObj.SetLocalAxes(new_frame_1[0],frame_local[0],frame_local[1]);
    new_frame_2=SapModel.FrameObj.AddByPoint(new_point[0],frame_pt1);
    SapModel.FrameObj.SetSection(new_frame_2[0],frame_section);
    for i in range(len(frame_grps[1])):
        if(frame_grps[1][i]!='All'):
            SapModel.FrameObj.SetGroupAssign(new_frame_2[0],frame_grps[1][i]);
    SapModel.FrameObj.SetModifiers(new_frame_2[0],frame_mods[0]);
    SapModel.FrameObj.SetLocalAxes(new_frame_2[0],frame_local[0],frame_local[1]);
    SapModel.View.RefreshView(True);
    return None
 
Hi Daniel,

Thanks for the reply, I do understand that you would be busy, sorry for troubling you. But thanks again.

I am selecting the points through the interface and using GetSelected function.

In the python generated ctypes file there is EditPoint class, which has few functions as given below, but there is no information in the .chm file, likewise there are many such functions in the generated python file for which we dont have any information in .chm file. like for example cSectionCut.

class cEditPoint(comtypes.gen._00020430_0000_0000_C000_000000000046_0_2_0.IDispatch):
_case_insensitive_ = True
_iid_ = GUID('{67761402-B408-4B43-A72E-4A434C5EAE78}')
_idlflags_ = ['dual', 'oleautomation']
cEditPoint._methods_ = [
COMMETHOD([dispid(1)], HRESULT, 'Align',
( ['in'], c_int, 'MyType' ),
( ['in'], c_double, 'Ordinate' ),
( ['in', 'out'], POINTER(c_int), 'NumberPoints' ),
( ['in', 'out'], POINTER(_midlSAFEARRAY(BSTR)), 'PointName' ),
( ['out', 'retval'], POINTER(c_int), 'pRetVal' )),
COMMETHOD([dispid(2)], HRESULT, 'ChangeCoordinates',
( ['in'], BSTR, 'Name' ),
( ['in'], c_double, 'X' ),
( ['in'], c_double, 'Y' ),
( ['in'], c_double, 'Z' ),
( ['out', 'retval'], POINTER(c_int), 'pRetVal' )),
COMMETHOD([dispid(3)], HRESULT, 'ChangeCoordinates_1',
( ['in'], BSTR, 'Name' ),
( ['in'], c_double, 'X' ),
( ['in'], c_double, 'Y' ),
( ['in'], c_double, 'Z' ),
( ['in', 'optional'], VARIANT_BOOL, 'NoRefresh', False ),
( ['out', 'retval'], POINTER(c_int), 'pRetVal' )),
COMMETHOD([dispid(4)], HRESULT, 'Connect',
( ['in', 'out'], POINTER(c_int), 'NumberPoints' ),
( ['in', 'out'], POINTER(_midlSAFEARRAY(BSTR)), 'PointName' ),
( ['out', 'retval'], POINTER(c_int), 'pRetVal' )),
COMMETHOD([dispid(5)], HRESULT, 'Disconnect',
( ['in', 'out'], POINTER(c_int), 'NumberPoints' ),
( ['in', 'out'], POINTER(_midlSAFEARRAY(BSTR)), 'PointName' ),
( ['out', 'retval'], POINTER(c_int), 'pRetVal' )),
COMMETHOD([dispid(6)], HRESULT, 'Merge',
( ['in'], c_double, 'MergeTol' ),
( ['in', 'out'], POINTER(c_int), 'NumberPoints' ),
( ['in', 'out'], POINTER(_midlSAFEARRAY(BSTR)), 'PointName' ),
( ['out', 'retval'], POINTER(c_int), 'pRetVal' )),
]

thanks for the code you have shared above.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor