Using pyautocad or win32.com to draw Revision Cloud

Using pyautocad or win32.com to draw Revision Cloud

cheungcaptain1
Explorer Explorer
1,399 Views
7 Replies
Message 1 of 8

Using pyautocad or win32.com to draw Revision Cloud

cheungcaptain1
Explorer
Explorer

Hello everyone

May i know is there any way to instruct AutoCAD to drawing the revision cloud??

 

 

0 Likes
Accepted solutions (1)
1,400 Views
7 Replies
Replies (7)
Message 2 of 8

Kent1Cooper
Consultant
Consultant

Describe what you are looking for that the REVCLOUD command doesn't do.

Kent Cooper, AIA
0 Likes
Message 3 of 8

cheungcaptain1
Explorer
Explorer

-----

0 Likes
Message 4 of 8

cheungcaptain1
Explorer
Explorer
Currently, when I need to draw some lines or circles, I mainly use code like 

circleobj1 = acad.model.AddCircle(APoint(X+650,Y+100,0), radius)
lineobj1 = acad.model.AddLine(Line_StartPoint,Line_EndPoint)

but when I need to create a revision cloud on the drawing and indicate there is a change in the design, I cannot find the correct command to instruct Python to perform. The change in this stage is mainly on attribute value, but I need to tell others that there is a change.

The code below is a trial idea of how I find out the attribute I am looking for in the block, get the x & y coordinates of that attribute & alignment etc.  

for entity in acad.ActiveDocument.ModelSpace:
    time.sleep(0.5)
    name = entity.EntityName
    print(name)
   
    if name == 'AcDbBlockReference':
        HasAttributes = entity.HasAttributes
        if HasAttributes:
            print(entity.Name)
            print(entity.Layer)
            # print(entity.ObjectID)
            for attrib in entity.GetAttributes():
                if attrib.TagString == "MC_1_ID_SUB_1" :
                    print("hi")
                    print(attrib.TagString)
                    print(attrib.InsertionPoint)
                    print(attrib.TextAlignmentPoint)
                    x_coor = attrib.TextAlignmentPoint[0]
                    y_coor = attrib.TextAlignmentPoint[1]
                    attri_text_height = attrib.height
                    string_length = len(attrib.TextString)

                    start = APoint(x_coor,y_coor,0)
                    end = APoint(x_coor+string_length*attri_text_height,y_coor-attri_text_height,0)
                    revisioncloud = Acad.model. <<<< here is the command I'm looking for, I have no idea how to draw the revision cloud line.
0 Likes
Message 5 of 8

Kent1Cooper
Consultant
Consultant

If, in Message 1, you want to use this to "instruct AutoCAD" to draw such a thing, I assume you must be wanting to do so in AutoCAD, so is there some reason to not just use AutoCAD's built-in command?  [Not that I could help with it -- I don't know that code language.]

Kent Cooper, AIA
0 Likes
Message 6 of 8

Sea-Haven
Mentor
Mentor

Ignoring python for the moment if you use lisp (nentsel "\nPick attribute") you can using the function textbox to get a box the size of text. Then use insertion point of attribute.

 

 

 

 

(setq ent (car (nentsel "\nPick an attribute ")))
(setq txt (cdr (assoc 1 (entget ent))))
(textbox (cons 1  txt))

((0.0 0.0 0.0) (22.9270833333333 2.5 0.0))

 

 

 

0 Likes
Message 7 of 8

daniel_cadext
Advisor
Advisor
Accepted solution

There isn’t a revcloud entity, you have to use the help of send command

Here’s a sample using my python wrappers, it's ActiveX, so you should be able port it to pyautocad

 

 

 

import traceback
from pyrx_imp import Rx
from pyrx_imp import Ge
from pyrx_imp import Gi
from pyrx_imp import Db
from pyrx_imp import Ap
from pyrx_imp import Ed

import AxApp24 as Ax

def PyRxCmd_doit() -> None:
    try:
        # get the app, doc and model space
        axApp = Ax.getApp()
        doc = axApp.ActiveDocument
        ms = doc.ModelSpace

        # coords for the cloud and create a polyline
        coords = [0, 0, 0, 0, 1000, 0, 1000, 1000, 0, 1000, 0, 0, 0, 0, 0]
        pl = ms.AddPolyline(coords)
        
        #use send command to create the revcloud 
        handle = '(handent "{}")'.format(pl.Handle)
        doc.SendCommand("revcloud A {} Object {} Y ".format(200, handle))

    except Exception as err:
        traceback.print_exception(err)

 

 

 

rev.png

Python for AutoCAD, Python wrappers for ARX https://github.com/CEXT-Dan/PyRx
0 Likes
Message 8 of 8

cheungcaptain1
Explorer
Explorer

It seem i found out my own solution on how to draw the cloud on specific attribute.

I know that isn't a good command or just sending the required information to autocad, but that fulfil my needs.

code are as below:

 

acad.ActiveDocument.SendCommand("revcloud"+ chr(13) + "arc" +str(attri_text_height) + chr(13) + str(x_coor) +chr(44) + str(y_coor)+ chr(13) + str(end_x) +chr(44) +str(end_y)+chr(13))
 
Btw, thanks for the support from all of you guys, i will try to understand your suggestion as well as i know my code is low level and need to be improve.