Jump to content

Search the Community

Showing results for tags 'python'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • CADTutor
    • News, Announcements & FAQ
    • Feedback
  • AutoCAD
    • AutoCAD Beginners' Area
    • AutoCAD 2D Drafting, Object Properties & Interface
    • AutoCAD Drawing Management & Output
    • AutoCAD 3D Modelling & Rendering
    • AutoCAD Vertical Products
    • AutoCAD LT
    • CAD Management
    • AutoCAD Bugs, Error Messages & Quirks
    • AutoCAD General
    • AutoCAD Blogs
  • AutoCAD Customization
    • The CUI, Hatches, Linetypes, Scripts & Macros
    • AutoLISP, Visual LISP & DCL
    • .NET, ObjectARX & VBA
    • Application Beta Testing
    • Application Archive
  • Other Autodesk Products
    • Autodesk 3ds Max
    • Autodesk Revit
    • Autodesk Inventor
    • Autodesk Software General
  • Other CAD Products
    • BricsCAD
    • SketchUp
    • Rhino
    • SolidWorks
    • MicroStation
    • Design Software
    • Catch All
  • Resources
    • Tutorials & Tips'n'Tricks
    • AutoCAD Museum
    • Blocks, Images, Models & Materials
    • Useful Links
  • Community
    • Introduce Yourself
    • Showcase
    • Work In Progress
    • Jobs & Training
    • Chat
    • Competitions

Categories

  • Programs and Scripts
  • 2D AutoCAD Blocks
  • 3D AutoCAD Blocks
  • Images
    • Backgrounds

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Found 2 results

  1. I am new to automating drawings in Autocad. I am using win32com to access autocad. I am using AddDimAligned function to add dimension but having trouble placing the text above the dimension line as the error is saying can not be set. Here is my code - class AutoCAD: def __init__(self): try: self.acad = win32com.client.Dispatch("AutoCAD.Application") time.sleep(2) self.acad.Visible = True self.doc = self.acad.ActiveDocument self.modelspace = self.doc.ModelSpace time.sleep(2) self.linetypes = self.doc.Linetypes self.layers = self.doc.Layers try: self.dimensionstyle = self.doc.DimStyles.Item("DIM") except Exception as e: print(f"Error: DIM dimension style not found. Creating it... {e}") # Create a new dimension style 'DIM' if it doesn't exist self.dimensionstyle = self.doc.DimStyles.Add("DIM") print("DIM dimension style created.") if self.modelspace.Count > 0: self.open_new_drawing() except Exception as e: raise AutoCADError(f"Error initializing AutoCAD: {e}") def add_dimension(self, dimension): try: distance_mm = dimension.convert_to_mm() dimension_obj = None if dimension.dimension_type == DimensionType.ALIGNED: dimension_obj = self.modelspace.AddDimAligned(dimension.start_point.to_variant(), dimension.end_point.to_variant(), dimension.text_point.to_variant()) elif dimension.dimension_type == DimensionType.LINEAR: dimension_obj = self.modelspace.AddDimLinear(dimension.start_point.to_variant(), dimension.end_point.to_variant(), dimension.text_point.to_variant()) elif dimension.dimension_type == DimensionType.ANGULAR: dimension_obj = self.modelspace.AddDimAngular(dimension.start_point.to_variant(), dimension.end_point.to_variant(), dimension.text_point.to_variant()) elif dimension.dimension_type == DimensionType.RADIAL: dimension_obj = self.modelspace.AddDimRadial(dimension.start_point.to_variant(), dimension.end_point.to_variant(), dimension.text_point.to_variant()) elif dimension.dimension_type == DimensionType.DIAMETER: dimension_obj = self.modelspace.AddDimDiameter(dimension.start_point.to_variant(), dimension.end_point.to_variant(), dimension.text_point.to_variant()) dimension_obj.TextOverride = f"{distance_mm:.0f}" # Set the dimension text to the calculated distance # self.dimensionstyle.TextAlign = 3 # 3 = centered text # self.dimensionstyle.TextOffset = 5 return dimension_obj except Exception as e: raise AutoCADError(f"Error adding dimension: {e}") def edit_dim_properties(self, dim,height=0.1,gap=0.02, units_precision=2, arrow_head_size=0.1,text_offset=5 ): try: dim.TextHeight = height dim.TextGap = gap dim.PrimaryUnitsPrecision = units_precision dim.ArrowheadSize = arrow_head_size dim.TextOffset = text_offset except Exception as e: raise AutoCADError(f"Error editing dimension properties: {e}")
  2. I have Civil 3D 2012 with ArcGIS for AutoCAD 300. I want to read the extents of a polygon in the drawing. Feature Class in A4A300 = Boundaries, the CAD layer is PROP-BNDY, there is only one polygon on that layer since it is the perimeter of the site. Do I have to convert the polygon to a temporary shapefile, read it, and then delete it? I will be using the boundary extents plus a constant in all directions to clip raster images. The process should not involve user input. I have 30 directories that I will be looping through, a drawing file in each directory and a polygon in each drawing. I have the python routines for creating a list of directories that have the *map.dwg files in them and I'm familiar with clipping the rasters, I just cannot find how to read the polygon extents in the dwg file. You help is greatly appreciated!!
×
×
  • Create New...