Recent Posts

Pages: [1] 2 3 ... 10
1
.NET / Re: Copy blocks in same drawing
« Last post by sresh on Today at 05:29:01 am »
Amazing!! This is what exactly I wanted. Thank you so much!! You saved my life.

I also want to attach a line to the block on adding the second time onward. I will work on it and will share the code.

Thanks  :-)
2
.NET / Re: Copy blocks in same drawing
« Last post by gile on Today at 04:51:38 am »
Try the following CopyBlock() method.
It uses the cloning process shown in the link I provided.
It requires  3 arguments:
  • the database in which some block references to copy are supposed to be inserted and have to be copied, this can be either a side database or the active document one (which makes testing easier) ;
  • the name of the block to search and copy ;
  • a transformation matrix (Matrix3d instance) to apply to the copied block repeferences

Code - C#: [Select]
  1.        private void CopyBlock(Database db, string blockName, Matrix3d xform)
  2.        {
  3.            using (Transaction tr = db.TransactionManager.StartTransaction())
  4.            {
  5.                BlockTableRecord modelSpace = (BlockTableRecord)tr.GetObject(
  6.                    SymbolUtilityServices.GetBlockModelSpaceId(db), OpenMode.ForWrite);
  7.                RXClass blockRefClass = RXClass.GetClass(typeof(BlockReference));
  8.                List<BlockReference> clones = new List<BlockReference>();
  9.                foreach (ObjectId id in modelSpace)
  10.                {
  11.                    if (id.ObjectClass == blockRefClass)
  12.                    {
  13.                        BlockReference br = (BlockReference)tr.GetObject(id, OpenMode.ForRead);
  14.                        if (br.Name == blockName)
  15.                        {
  16.                            clones.Add((BlockReference)br.Clone());
  17.                        }
  18.                    }
  19.                }
  20.                foreach (BlockReference clone in clones)
  21.                {
  22.                    clone.TransformBy(xform);
  23.                    modelSpace.AppendEntity(clone);
  24.                    tr.AddNewlyCreatedDBObject(clone, true);
  25.                }
  26.                tr.Commit();
  27.            }
  28.        }

calling example (copies "XYZ" references and moves them 15 units along X axis):
Code - C#: [Select]
  1. Database db = HostApplicationServices.WorkingDatabase;
  2. Matrix3d xform = Matrix3d.Displacement(new Vector3d(15.0, 00.0, 0.0));
  3. CopyBlock(db, "XYZ", xform);
3
.NET / Re: Copy blocks in same drawing
« Last post by sresh on Today at 02:16:20 am »
Code: [Select]
Entity ent = (Entity)tr.GetObject(id, OpenMode.ForRead);
 
                            if (ent is BlockReference)
                            {
                                BlockReference bref = (BlockReference)tr.GetObject(ent.ObjectId, OpenMode.ForRead);

Is this what you meant? It is in the above code.
4
AutoLISP (Vanilla / Visual) / Re: Modelling error - snub dodecahedron modeling
« Last post by ribarm on July 03, 2015, 01:36:49 pm »
The same issue with SNUB CUBOCTAHEDRON...

VIDEO :
https://youtu.be/Hw-zp-80lkw

To obtain real 3DSOLID entity, you'll have to be even more precise... So you'll have to scale RED CIRCLE by factor : 1.000180852

M.R.
5
AutoLISP (Vanilla / Visual) / Re: Get Dynamic Block Parameter
« Last post by Lee Mac on July 03, 2015, 08:54:54 am »
Thanks Lee Mac :)

But i wanna Select block in different way.

You're welcome.

The posted code was only an example - you can pass my LM:getdynpropvalue function a Block Reference vla-object obtained through any means, not just from an entsel selection.

Lee
6
.NET / Re: Copy blocks in same drawing
« Last post by gile on July 03, 2015, 07:56:41 am »
The link you have provided is only for entities. But I am looking for block references, where in I have to consider the insertion point and the name.

Thanks

Did you try this way with block references (which are entities) ? if so, could you provide you test code ?
7
AutoLISP (Vanilla / Visual) / Re: Get Dynamic Block Parameter
« Last post by chowter on July 03, 2015, 07:35:39 am »
Thanks Lee Mac :)

But i wanna Select block in different way. For example:

I have base address for all blocks and each block have own base address( first = 1, second = 2 etc). So if i enter base address (for example 100: First block would have 101 adress second 102). (look new attached file)

My lisp code:

Code: [Select]
Set dynamic block parameters

(defun myModifyBk ( lstProp / ss index cnt oBkRef oProps i j oSBReferenceProperty)
(vl-load-com)
(SETQ ss (SSGET "_A"))
(setq index 0
      cnt (sslength ss)
)

(while (< index cnt)
(setq e (ssname ss index))
(setq oBkRef (vlax-ename->vla-object e))
   
(setq oProps (vlax-variant-value (vla-GetDynamicBlockProperties oBkRef)))

(setq i (vlax-safearray-get-l-bound oProps 1))
(while (<= i (vlax-safearray-get-u-bound oProps 1))
(setq oSBReferenceProperty (vlax-safearray-get-element oProps i))
(print (strcat (vla-get-PropertyName oSBReferenceProperty) "="))
(princ (vlax-variant-value (vla-get-value oSBReferenceProperty)))
(setq i (1+ i))
)

(setq j 0)
(while (< j (length lstProp))
(setq sProp (strcase (nth j lstProp)))
(setPropValue oProps sProp (nth (+ 1 j) lstProp))
(setq j (+ 2 j))
) ;while < j (length lstProp)

(setq index (1+ index))
) ;while < index cnt


(princ)
)

(defun setPropValue (oProps sProp Val / i oSBReferenceProperty sPName iFound)
(setq i (vlax-safearray-get-l-bound oProps 1))
(setq iFound 0)
(while (and (<= i (vlax-safearray-get-u-bound oProps 1)) (= iFound 0))
(setq oSBReferenceProperty (vlax-safearray-get-element oProps i))
(setq sPName (vla-get-PropertyName oSBReferenceProperty))
(if (= (strcase sPName) sProp)
(progn
(print (strcat "_Old value of " sPName "="))
(princ (vlax-variant-value (vla-get-value oSBReferenceProperty)))
(vla-put-value oSBReferenceProperty
(vlax-make-variant Val
(vlax-variant-type (vla-get-value oSBReferenceProperty))
)
)
(print "New value=")
(princ (vlax-variant-value (vla-get-value oSBReferenceProperty)))
(setq iFound 1)
)
)

(setq i (1+ i))
)
(princ)
)





;--------------------------------
;Get Base adress from block

;; Get Dynamic Block Property Value  -  Lee Mac
;; Returns the value of a Dynamic Block property (if present)
;; blk - [vla] VLA Dynamic Block Reference object
;; prp - [str] Dynamic Block property name (case-insensitive)

(defun LM:getdynpropvalue ( blk prp )
    (setq prp (strcase prp))
    (vl-some '(lambda ( x ) (if (= prp (strcase (vla-get-propertyname x))) (vlax-get x 'value)))
        (vlax-invoke blk 'getdynamicblockproperties)
    )
)

        (if (and (setq e (car (entsel "\nSelect block: "))) ;(entsel "\nSelect block: ")
                 (= "INSERT" (cdr (assoc 0 (entget e))))
            )
            (print (setq x (LM:getdynpropvalue (vlax-ename->vla-object e) "base")))
        )




;----------
;Enter adress

(setq
  adres (getint "\nEnter adress[0-1023]: ")
);setq

;----------
;Set pins

;----------
;9

(if (>= adres 512)
  (progn
    (setq
  adres (- adres 512)
);setq
    (setq x9 1)
  );progn
  (progn ;else
    (setq x9 0)
  );progn
);if

;----------
;8

(if (>= adres 256)
  (progn
    (setq
  adres (- adres 256)
);setq
    (setq x8 1)
  );progn
  (progn ;else
    (setq x8 0)
  );progn
);if

;----------
;7

(if (>= adres 128)
  (progn
    (setq
  adres (- adres 128)
);setq
    (setq x7 1)
  );progn
  (progn ;else
    (setq x7 0)
  );progn
);if

;----------
;6

(if (>= adres 64)
  (progn
    (setq
  adres (- adres 64)
);setq
    (setq x6 1)
  );progn
  (progn ;else
    (setq x6 0)
  );progn
);if

;----------
;5

(if (>= adres 32)
  (progn
    (setq
  adres (- adres 32)
);setq
    (setq x5 1)
  );progn
  (progn ;else
    (setq x5 0)
  );progn
);if

;----------
;4

(if (>= adres 16)
  (progn
    (setq
  adres (- adres 16)
);setq
    (setq x4 1)
  );progn
  (progn ;else
    (setq x4 0)
  );progn
);if

;----------
;3

(if (>= adres 8)
  (progn
    (setq
  adres (- adres 8)
);setq
    (setq x3 1)
  );progn
  (progn ;else
    (setq x3 0)
  );progn
);if

;----------
;2

(if (>= adres 4)
  (progn
    (setq
  adres (- adres 4)
);setq
    (setq x2 1)
  );progn
  (progn ;else
    (setq x2 0)
  );progn
);if

;----------
;1

(if (>= adres 2)
  (progn
    (setq
  adres (- adres 2)
);setq
    (setq x1 1)
  );progn
  (progn ;else
    (setq x1 0)
  );progn
);if

;----------
;0

(if (>= adres 1)
  (progn
    (setq
  adres (- adres 1)
);setq
    (setq x0 1)
  );progn
  (progn ;else
    (setq x0 0)
  );progn
);if

;Print adress
(princ "\n_PROFIsafe Address: ")
(princ x9)
(princ x8)
(princ x7)
(princ x6)
(princ x5)
(princ x4)
(princ x3)
(princ x2)
(princ x1)
(princ x0)




;----------
;0

(if (>= x0 1)
  (progn
(myModifyBk (list "Flip_state0" 1))
  );progn
  (progn ;else
(myModifyBk (list "Flip_state0" 0))
  );progn
);if

;----------
;1

(if (>= x1 1)
  (progn
(myModifyBk (list "Flip_state1" 1))
  );progn
  (progn ;else
(myModifyBk (list "Flip_state1" 0))
  );progn
);if

;----------
;2

(if (>= x2 1)
  (progn
(myModifyBk (list "Flip_state2" 1))
  );progn
  (progn ;else
(myModifyBk (list "Flip_state2" 0))
  );progn
);if
;----------
;3

(if (>= x3 1)
  (progn
(myModifyBk (list "Flip_state3" 1))
  );progn
  (progn ;else
(myModifyBk (list "Flip_state3" 0))
  );progn
);if

;----------
;4

(if (>= x4 1)
  (progn
(myModifyBk (list "Flip_state4" 1))
  );progn
  (progn ;else
(myModifyBk (list "Flip_state4" 0))
  );progn
);if

;----------
;5

(if (>= x5 1)
  (progn
(myModifyBk (list "Flip_state5" 1))
  );progn
  (progn ;else
(myModifyBk (list "Flip_state5" 0))
  );progn
);if

;----------
;6

(if (>= x6 1)
  (progn
(myModifyBk (list "Flip_state6" 1))
  );progn
  (progn ;else
(myModifyBk (list "Flip_state6" 0))
  );progn
);if

;----------
;7

(if (>= x7 1)
  (progn
(myModifyBk (list "Flip_state7" 1))
  );progn
  (progn ;else
(myModifyBk (list "Flip_state7" 0))
  );progn
);if

;----------
;8

(if (>= x8 1)
  (progn
(myModifyBk (list "Flip_state8" 1))
  );progn
  (progn ;else
(myModifyBk (list "Flip_state8" 0))
  );progn
);if

;----------
;9

(if (>= x9 1)
  (progn
(myModifyBk (list "Flip_state9" 1))
  );progn
  (progn ;else
(myModifyBk (list "Flip_state9" 0))
  );progn
);if


;----------
;**************************************************END

I would like to happen in such a way that when entering command (eg . Setprofi ) script automatically adjust the pins in all blocks across the page .
8
.NET / Using a name of the system variable in the referenced DLL of CSPROJ
« Last post by Andrey Bushman on July 03, 2015, 06:39:17 am »
Windows 7 x64, MS Visual Studio 2013 Premium.

I created a new system variable ObjectARX 2009 with the D:\SDK\Autodesk\AutoCAD\ObjectARX 2009 value. Windows Explorer opens right location for %ObjectARX 2009%. I want use this variable in my CSPOJ-file for the references:

Code - XML: [Select]
  1. <Reference Include="AcMgd">
  2.  <HintPath>$(ObjectARX 2009)\inc-x64\AcMgd.dll</HintPath>
  3.  <Private>False</Private>
  4. </Reference>
But Visual Studio doesn't see AcMgd.dll file.



File exists: .NET Reflector opens it for %ObjectARX 2009%\inc-x64\AcMgd.dll way.

If I use the full path, then it works fine:

Code - XML: [Select]
  1. <Reference Include="AcMgd">
  2.  <HintPath>D:\SDK\Autodesk\AutoCAD\ObjectARX 2009\inc-x64\AcMgd.dll</HintPath>
  3.  <Private>False</Private>
  4. </Reference>

Also, fine works such variant:

Code - XML: [Select]
  1. <PropertyGroup>
  2.  <ObjectARX_Location>D:\SDK\Autodesk\AutoCAD\ObjectARX 2009</ObjectARX_Location>
  3. </PropertyGroup>
  4.  
  5. <ItemGroup>
  6.  <Reference Include="AcMgd">
  7.    <HintPath>$(ObjectARX_Location)\inc-x64\AcMgd.dll</HintPath>
  8.    <Private>False</Private>
  9.  </Reference>
  10. </ItemGroup>

Why Visual Studio doesn't see my reference with the system variable?
9
.NET / Re: Copy blocks in same drawing
« Last post by sresh on July 03, 2015, 04:13:39 am »
The link you have provided is only for entities. But I am looking for block references, where in I have to consider the insertion point and the name.

Thanks
10
CAD Standards / Re: Lines
« Last post by Kerry on July 03, 2015, 04:12:23 am »
^^ ditto

The 0.5 pen was brown but we used Magenta for 0.5 lines.

We had this (not plottable) in the corner of our borders to 'remind' anyone ( clients ) who plotted our drawings.
Since that time almost all documents are issued PDF rather than dwg files.




Pages: [1] 2 3 ... 10